Exporting Large Datasets in DBeaver: Avoiding Memory Crashes and Dialect Errors
Learn how to use DBeaver's Export Data wizard to move large datasets to CSV or SQL without triggering OutOfMemory errors by optimizing fetch sizes and dialects.
08 Feb 2026, 01:14 UTC

The Problem: Memory Exhaustion During Data Export
When exporting large result sets from a database to CSV or SQL scripts, DBeaver can crash with an OutOfMemoryError. This happens because the default configuration may attempt to load too many rows into the application's JVM (Java Virtual Machine) heap memory before writing them to the disk.
The solution is to configure the Fetch Size and Export Format settings to stream data from the server to the file, rather than buffering it in memory.
Prerequisites
- DBeaver Community or Enterprise Edition installed.
- An active connection to a database with read permissions on the target table or query.
- Write permissions for the local directory where the export file will be saved.
Step-by-Step Export Procedure
Follow these steps to export a result set while maintaining application stability.
- Initiate Export: Run your
SELECTquery in the SQL Editor. Right-click anywhere in the results grid and select Export Data. - Select Target Format: Choose your output format from the list.
- CSV: Best for data analysis or importing into spreadsheets.
- SQL: Generates
INSERTstatements, useful for migrating data between database instances.
- Configure Extraction Settings: This is the critical step for large datasets. Locate the Fetch size field.
- Default: Often set to 10,000.
- Recommended for Large Sets: Set this to a lower value (e.g., 1,000 to 5,000) if you encounter crashes. This limits how many rows DBeaver holds in memory at once.
- Set Output Format Details:
- For CSV: Verify the delimiter (comma or semicolon) and ensure the encoding is set to
UTF-8to prevent character corruption. - For SQL: Select the Target Database dialect (e.g., PostgreSQL, MySQL, Oracle). If the target database differs from the source, selecting the correct dialect ensures the generated
INSERTsyntax is compatible.
- For CSV: Verify the delimiter (comma or semicolon) and ensure the encoding is set to
- Define Output File: Choose the directory and filename. Ensure the "Insert BOM" option is checked for CSVs intended for Microsoft Excel.
- Execute: Review the summary page and click Finish.
Comparison: CSV vs. SQL Insert Exports
| Feature | CSV Export | SQL Insert Export |
|---|---|---|
| Primary Use | Reporting, Data Analysis | Database Migration, Backups |
| Performance | High (Fast write speed) | Moderate (Slower to execute) |
| Portability | Universal | Dialect-dependent |
| Risk | Delimiter collisions in text | Syntax errors on target DB |
Verification and Diagnostics
To ensure the export was successful and the data is intact, perform the following checks:
- Row Count Validation: Run
SELECT COUNT(*) FROM tablein DBeaver and compare it to the line count of the exported CSV (subtracting the header row). - SQL Execution Test: If you exported to SQL, create a temporary test table in a development schema and execute the generated script. Check for
Syntax Errormessages which indicate a dialect mismatch. - Encoding Check: Open the file in a text editor (like VS Code or Notepad++) and verify that special characters (e.g., accented letters, symbols) are rendered correctly.
Rollback and Recovery
Because the export process reads data and writes to a local file without modifying the database state, there is no database rollback required. However, if the export fails midway:
- Delete Partial Files: Manually delete the incomplete
.csvor.sqlfile from your local directory to avoid importing partial data. - Clear Memory: If DBeaver becomes unresponsive, restart the application to clear the JVM heap before attempting the export again with a smaller Fetch size.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.