Menu

1 / 5

Column-Oriented Databases: Why Analytics Queries Are So Fast

DEV Community: backend·Abdeldjalil Chougui·about 4 hours ago
#S06LosaR
#devtobackend#devto#dev#columns#column
Long article (1042 words) — no AI summary yet.
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.