Partitioned Export with COPY Generates Excessively Many Small Files within Each Partition

Open
#152 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
sql
Domain
databases

Research direction

Start by reproducing the documented COPY command with Parquet partitioning and the FILENAME_PATTERN shown in the issue. Compare the generated files within a partition against the expected single-file output; done means the export no longer creates unnecessary small fragments for the reported workload.

Written by the indexing model from the issue text.

Description

Duckdb Version: 1.1.3 and 1.2.0

When using the COPY command to export data into Parquet format with a partition key (e.g., batch_id), DuckDB produces multiple very small files (approximately 50–100KB each). In our use case—exporting around 100 million line items (1 crore) into batches of 5,000 line items each—this results in roughly 20,000 separate partition directories and small file fragments within each.
Current output

\batch_id=1000\
     records_0.parquet (30kb)
     records_1.parquet(70kb)

Expected output

\batch_id=1000\
     records_0.parquet (100kb)

Command used to export :

COPY my_schema.my_table 
TO '/path/to/export' 
(FORMAT 'parquet', PARTITION_BY (batch_id), OVERWRITE_OR_IGNORE, FILENAME_PATTERN 'records_{i}');
Dominant language
C++
Stars
127
Forks
80
Avg merge
13h 41m
Merged PRs (30d)
44

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from duckdb/duckdb-java

All issues in duckdb/duckdb-java

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.