WW warin.me

DATA SYSTEMS · INTERACTIVE LAB

See, run and compare the physical work behind PostgreSQL, DuckDB and ClickHouse.

The useful question is not “which database wins?” It is “what work did the system avoid, defer, store or repeat?”

Checking isolated teaching runtimes…
ROWS10K
100K
1M
one deterministic sales model

34-SLIDE TEACHING DECK

From Views to Incremental Analytics

Begin with the conceptual journey before running the laboratories: VIEW, materialization, row versus column storage, incremental view maintenance, and the physical choices behind modern OLAP.

VIEWMaterialized ViewRow vs ColumnIVM · ΔThree Labs

CONCEPTUAL ER DIAGRAM

The business model behind the flat teaching table

Each dimension describes many sale events. The laboratories intentionally embed these attributes in sales so every engine receives one portable physical contract.

Conceptual relationship · 1:N Physical lab · one denormalized sales table

ONE QUESTION · THREE COMPUTATION PLACEMENTS

Choose the boundary before choosing the product.

PostgreSQLrows + reusable SQL + stored snapshot
DuckDBembedded process + local files
ClickHousecolumnar parts + incremental states

THREE LABS · THREE DIFFERENT NEEDS

Begin with the work you need the data system to perform.

COMMON DATA CONTRACT

One sales event, one grain, one meaning—implemented in three engines

A fair comparison needs more than similar column names. Every engine receives the same row meaning, deterministic values, measures and analytical question. Storage types change only where an engine requires its native equivalent.

FACT TABLEsalesone row = one completed sale event
PRIMARY IDENTIFIERsale_idunique event; PostgreSQL enforces the PK
EVENT TIMEsale_timestampbusiness time used for daily rollups
DATA VOLUME10K · 100K · 1Mthe same rules at each bounded scale
FACTsalesgrain: sale event

Identity & time

sale_id · BIGINT / UInt64sale_timestamp · TIMESTAMP / DateTime

Descriptive dimensions

region · provincecategory · productchannel · customer_id

Atomic inputs

quantity · unit_price · discount

Derived measures

revenue · cost · profit
01

Stable semantics

Region, category and channel mean the same thing in every lab; performance cannot be “won” by silently changing the question.

02

Comparable workload

The baseline groups sales by region and category and computes order count and revenue. Engine-specific experiments then reveal their strengths.

03

Controlled synthetic data

No student or production record is used. Deterministic formulas make every reset reproducible.

This is intentionally a compact teaching schema, not a full enterprise model. In production, customer, product and geography commonly become governed dimensions with explicit history, quality and privacy rules.

MASTER COMPARISON

What each design makes cheap—and what it asks you to maintain

SystemComputation locationPhysical reuseFreshness modelBest teaching question
PostgreSQLdatabase servermaterialized rowsexplicit refreshlogic vs stored result
DuckDBweb processParquet + local tablefile/table replacementserverless analytical scan
ClickHouseisolated OLAP serversorted column parts + aggregate statesnew inserted blockslayout and incremental work