Back to questions
JuniorTheoryVery common
Greenplum offers heap, append-optimized row and append-optimized column tables — which fits which warehouse table?
Heap for small tables with frequent UPDATE, DELETE or single-row inserts, like load control tables. Append-optimized for data loaded in batches and rarely changed; column-oriented and compressed for wide facts whose queries read a few columns.
- Making every table append-optimized column, then running frequent single-row UPDATE and DELETE against it
- Choosing column orientation for tables whose queries read whole rows, where it only multiplies files
- Running several batch UPDATE or DELETE jobs on the same append-optimized table at once
- How does Greenplum delete a row from an append-optimized table, and when does that space come back?
- Why can old partitions of one fact table use column storage with compression while the current one stays heap?
The three table kinds in Greenplum and its forks Arenadata DB and Greengage DB:
| heap | append-optimized, row | append-optimized, column | |
|---|---|---|---|
| How it stores | PostgreSQL pages; an update writes a new row version | rows appended to the end of files | each column is a separate file on every segment |
| Strength | frequent UPDATE, DELETE, single-row inserts | batch loads, reading whole rows | scans of a few columns of a wide table, compression |
| Weakness | no compression, bloats with dead rows | single-row changes are expensive | writes and all-column queries cost more, many files |
| Typical table | load control table, small changing dimension | wide extract read in full | fact with hundreds of columns, analytic queries |
-- fact: loaded in batches, queries take 5–10 of 150 columns
CREATE TABLE fact_sales (sale_id bigint, customer_id bigint, sale_date date, amount numeric /* ... */)
WITH (appendoptimized = true, orientation = column, compresstype = zstd, compresslevel = 5)
DISTRIBUTED BY (sale_id);
-- load log: updated row by row after every step
CREATE TABLE etl_load_log (load_id bigint, step text, status text, updated_at timestamptz)
DISTRIBUTED BY (load_id);An append-optimized table supports UPDATE and DELETE but never rewrites a row in place: a deleted row is only marked in a visibility map, and VACUUM gets the space back. That makes single-row changes expensive, and batch UPDATE or DELETE jobs on one such table must not run concurrently. Storage can be set per partition: old months of a fact column-oriented and compressed, the current one, still being corrected, heap.