Run SELECT sum(amount) FROM sales WHERE year = 2025 on a table with a billion rows in a regular database, and you may wait minutes. Run the same query on ClickHouse, BigQuery or DuckDB, and it often comes back in seconds. Same data, same SQL. The difference is mostly about one decision: how the rows are laid out on disk.
Row storage: how most databases work
PostgreSQL, MySQL and SQL Server store data by row . All the values of one row sit together on a disk page:
page 1: [1, 2025-01-03, Algiers, 3, 1200] [2, 2025-01-03, Oran, 1, 400] ...
Enter fullscreen mode
Exit fullscreen mode
This is ideal for transactional work. Loading customer 42 means reading one place on disk and getting all their columns at once. Inserting an order writes one row in one place. Updating it touches one row.
Now take the analytics query. It needs only two columns, year and amount , out of perhaps twenty. With row storage, the database must still read every page, and every page is full of the eighteen columns it does not need.…