General
Read Less Instead of Reading Faster: Parquet, DuckDB and Period-Based Partitioning
A 40-second dashboard
Our data was in Parquet, it was read by DuckDB, and a single monthly report still took 40 seconds to open.
We are moving an organization's long-standing Oracle-based data warehouse and its reports to a modern architecture. Performance was one of the main reasons for the move: in the old system, reports with many JOINs over large tables ran slowly. In the new architecture, the data lives as Parquet files on MinIO, is processed with DuckDB, and is served through PostgreSQL to Vispeahen, the BI product developed in-house at BiSoft. We are also porting the reports from the old platform to Vispeahen one to one.
Most of these reports are fed by a single large fact table: about 660 million rows of transaction records, each tied to a monthly period. Users almost always query this table with a period filter, such as "September 2025" or "the year 2025".
We expected the reports to become noticeably faster on the new architecture. But when we moved the report showing consumption by device type to Vispeahen, we did not get the result we were hoping for: the report took 30 to 40 seconds, even for a single month.
On paper, everything looked right: a columnar file format, an engine designed for analytical queries, and a compute layer decoupled from object storage. Yet while the user asked for a single month, the system was reading almost the entire table.
In this post I walk through where the problem came from, step by step, using the internals of Parquet and DuckDB. Then I show how we reorganized the data by period, and how the same report query dropped from 40 seconds to 1-2 seconds, with measurements.
This work is part of the architecture described in Serdar Güler's post Oracle'dan DuckDB ve Vispeahen'e: Bir BI Modernizasyon Hikayesi (in Turkish). Here I look in more detail at what the idea of "reading less instead of reading faster", briefly mentioned there, means in practice.
Architecture at a glance
Data is transferred from the source database to Parquet files on MinIO, transformed with DuckDB inside Airflow, and served to Vispeahen through PostgreSQL. This post is about a single fact table in this flow: about 660 million rows and ~38 GiB, tied to monthly periods.
Almost every report queries this table with a period filter.

Data flow | From source to Vispeahen
PostgreSQL does not store the data here. Thanks to the pg_duckdb extension, it acts as a view layer that reads the Parquet files on MinIO with the DuckDB engine. This way, both Vispeahen and technical teams can access the same data with standard SQL.
Looking inside Parquet
Parquet stores a file column by column rather than row by row, and keeps a summary of every part at the end of the file. The key to both the problem and the solution lies in these summaries.
Columnar storage. In a row-based format, if you ask for 3 columns from an 80-column table, all 80 columns are read from disk. In Parquet, values of the same column sit next to each other, so only the 3 requested columns are read. Because values of the same type sit together, compression also works much better.
File structure. A Parquet file has three layers:
Row group: Horizontal slices of the rows. In our files, each row group held about 1 million rows.
Column chunk: All values of a single column within a row group.
Page: Small, compressed and encoded (dictionary, RLE) pieces of a column chunk.
Footer and statistics. The footer at the end of the file stores the schema and, for every column of every row group, statistics: the smallest value (min), the largest value (max) and the null count. A reader can look at the footer before opening the rest of the file and work out which row groups could contain the value it is looking for.

Parquet file structure | Row group, column chunk, page, footer
The file is split horizontally into row groups, and each row group vertically into columns. A reader first reads the footer, then fetches only the columns it needs from only the row groups it needs.
For example, imagine a query that filters for the September 2025 period. If a row group's period column has a min value of January 2018 and a max value of June 2018, that row group cannot contain September 2025 and can be skipped entirely. The narrower the ranges these statistics cover, the more data can be skipped without being read.
How does DuckDB read this file?
DuckDB uses the information Parquet provides to avoid reading unnecessary columns and unnecessary row groups at all.
DuckDB is an analytical database that runs inside the application as a library (in-process), not as a separate server. In our architecture it is used both as the transformation engine inside Airflow tasks and as the query engine inside PostgreSQL through the pg_duckdb extension. It processes data not row by row, but in vectors of thousands of values, in parallel across multiple cores.
When reading a Parquet file, it does three things:
Projection pushdown: It identifies the columns used in the query and reads only their column chunks.
Filter pushdown: It pushes the
WHEREcondition down to the scan. It checks the min/max statistics in the footer and skips row groups that cannot possibly match the condition.Partial reads (HTTP range requests): If the file sits on object storage (MinIO in our case), it does not download the whole file. It requests only the byte ranges it needs.
The last point matters: when reading from object storage, what really determines the duration is how many bytes and how many requests travel over the network. The more row groups filter pushdown can skip, the fewer bytes are fetched and the faster the query finishes.
All of these mechanisms were working in our system as well. The EXPLAIN ANALYZE output clearly showed the filter being pushed down to the scan. So why was the report taking 40 seconds?
Root cause: the mechanism was there, the information wasn't
Filter pushdown was working, but the row group statistics were not enough to eliminate any row group. The data had been written to the file with the periods mixed together.
To see this, we read the file's footer directly with DuckDB's parquet_metadata() function. This function returns the min/max statistics for every column of every row group. When we looked at the period column, the result was clear:
Metric | Value |
|---|---|
Total rows | ~661 million |
Number of row groups | 662 |
Median period range per row group | 25 years |
Candidate row groups for September 2025 | 584 / 662 |
Almost every row group covered all periods, from the start of the table to the end. If you asked DuckDB "which row groups could contain September 2025?", the answer was "almost all of them".
The EXPLAIN ANALYZE output confirmed this. A simple query summing a single month returned 183 thousand rows, but 1002 MiB of data and 1058 HTTP requests went over the network. The query took 8.3 seconds. The actual query from the Vispeahen report contained more columns and grouping, which pushed the duration up to 40 seconds.
So the problem was neither in Parquet nor in DuckDB. The mechanism was there, but it had no information to work with. For the statistics to be useful, the data had to be physically grouped by the column the query filters on.
Solution: period-based partitioning
We split the table into separate files by the period column. Since each file belongs to a single period, the statistics of the row groups inside it stay narrow by construction.
The nice part of this approach is that the order inside a file no longer matters. However parallel writes, memory settings or merge steps distribute the rows, every row group in a monthly file contains only that month.
Mixed granularity. Splitting every period by month looks like the most sensible option at first. But every file has its own footer, and every file means at least one extra HTTP request. Since older years are rarely queried, splitting them by month would only add metadata overhead. So we used three different granularities:
Periods before 2015: one file per year (
events_2012.parquet)2015 and later: one file per month (
events_2025-09.parquet)Invalid or edge-case dates: a single
events_other.parquetfile
In the end, about 660 million rows were spread across 168 files.

Period-based partitioning | 168 files
For a query asking for a single month, the relevant row groups are now gathered in a single file. The footers of the other files are read, but their data is not.
No additional sorting. Different reports use this table with different breakdowns. Sorting the inside of the files by, say, device type or region would speed up one report without helping the others. The period was the filter common to all reports.
Safe publishing and validation
A change made for performance should never compromise data correctness. That is why we do not write the partitions straight into the live folder. Every publish goes through these steps:
Write locally. The table is first written to the Airflow worker's disk with DuckDB's
COPY ... TO ... (PARTITION_BY part)command.Compare per period. For each partition, the row count and the totals of the main measures are computed and compared with the source table's values for the same period. If a single period differs, the task fails and stops, and no file is uploaded.
Upload. Files that pass the check are uploaded to object storage.
Clean up. Old files that no longer have a counterpart are deleted.
Update the view. The view is read from its own definition (
pg_get_viewdef) and recreated with only the file list changed. This step runs only when the list has actually changed, for example when a new month's file appears.
This setup has a side benefit. Because the check runs per period, when a difference shows up, the logs point directly to the period it is in. Also, the daily refresh can rewrite only the files of the periods that changed; with a single file, the whole table had to be rewritten every time.
Results
For period-filtered queries, duration dropped 10 to 50 times and the data read dropped about 20 times. For a full scan without a filter, the partitioned layout is 2 times slower.
We ran the measurements in the same environment, with the same queries, through PostgreSQL with pg_duckdb. The report pattern follows the structure of the query Vispeahen actually sends for this report: a device type and year filter, grouped at the subscriber and serial number level.
Scenario | Unsorted single file | Partitioned (168 files) |
|---|---|---|
Single period, simple sum | 8.3 s · 1002 MiB | 0.9 s · 50 MiB |
Report query, monthly (1st / 2nd run) | 39.7 / 40.5 s | 2.4 / 0.8 s |
Report query, yearly | 57.4 s | 5.7 s |
Full scan, no filter | 9.8 s | 19.3 s |
Duration now scales with the scope of the query. With the unsorted file, monthly and yearly queries cost almost the same, because in both cases most of the row groups had to be read. With the partitioned layout, a month takes 1-2 seconds and a year 5-6 seconds. The narrower the period a query asks for, the less data is read.
The second-run difference. With the partitioned layout, the second run dropped from 2.4 seconds to 0.8 seconds. While DuckDB's footer cache is warm, the files' metadata is not fetched again. With the unsorted file, the cache makes no difference, because almost all of the cost comes from reading the data itself.
A performance loss we accepted on purpose: the unfiltered scan. For a query with no period filter, the partitioned layout is 2 times slower. Each of the 168 files needs its own request and footer read; a single large file has no such overhead. Since almost every query in our Vispeahen reports carries a period filter, we accepted this performance loss for the rare unfiltered scans. This result also confirms our decision to group older years into yearly files; had we split everything by month, the number of files and this overhead would have been much higher.
Looking back
Choosing a columnar format and a fast engine is only the beginning. The real gain comes from laying out the data so the engine can skip it.
Four lessons we took from this work:
Statistics only help if the data is organized. Parquet and DuckDB provide the mechanisms needed to read less data. Whether those mechanisms do anything is decided by how the data was written to the file.
Measure first, then design.
parquet_metadata()andEXPLAIN ANALYZEshowed us what the problem was without any guessing. The number of bytes read is a far more instructive metric than query duration.Physical design follows query behavior. We chose the partition column by looking at what users actually filter on. The same goes for granularity: recent periods that are queried often are monthly, older periods that are rarely queried are yearly.
Every optimization has a cost, and every optimization should come with a validation step. Filtered queries got faster and unfiltered scans got slower. We measured this and accepted it deliberately. And while reorganizing the data, we did not publish any period without comparing it to the source.
In the words of Serdar Güler's post: instead of trying to read unnecessary data faster, avoid reading it at all whenever possible.






