Databases for Data Engineers
A data engineer meets databases from two sides. On one side are application OLTP databases they extract from: PostgreSQL, its replicas, a change stream through CDC. On the other are the analytical warehouses they load into: columnar and MPP systems such as Greenplum and Redshift. ACID and normal forms are not repeated here. This topic covers how a database's internals hit an extract, a report, or a load.
In an interview it comes down to four questions. Why an analytical query does not belong on the OLTP primary, and how row storage differs from columnar, B-tree from LSM. Which snapshot of the data a query sees in PostgreSQL, and why a five-query report can disagree with itself. What happens on a replica: lag, canceled queries, slots that retain WAL. And how to lay out a large table across partitions, sort keys, and MPP segments so the engine skips unneeded work.
Versions in the text: PostgreSQL 18; Redshift and Greenplum (with its forks Arenadata DB and Greengage DB) without a version. Where a default changed, the version is named.
Topic map
- OLTP, OLAP, and storage — workload profiles, row and columnar storage, B-tree versus LSM, the WAL as the basis of durability, replication, and CDC.
- MVCC and isolation — row versions and snapshots, isolation levels in PostgreSQL 18 and how they differ from the standard, consistent snapshots for extracts and reports.
- Replication and slots — streaming replication, replica lag, hot-standby conflicts, replication slots and the WAL they retain, CDC slots included.
- Partitioning and MPP — partitioning, sharding, and sort keys, MPP distribution keys, redistribution and skew, Greenplum next to Redshift.
Common traps
| Mistake | Consequence |
|---|---|
| Running heavy aggregations on the OLTP primary | Application transactions wait for disk and cache, and the report is slow anyway |
Assuming BEGIN … COMMIT gives all queries one snapshot | Under Read Committed each query sees its own snapshot, and the totals disagree |
| Holding a snapshot for hours on the primary | VACUUM cannot remove dead versions, and tables bloat |
| Extracting from an async replica right after midnight | The replica lags, and the latest orders are missing from the extract |
| Leaving an inactive replication slot behind | The slot retains WAL, and the primary's disk fills up |
Deleting files from pg_wal by hand | The database may not come back after a crash |
| Distributing an MPP table by date | The whole daily load and every query for a day land on one segment |
Interview relevance
Databases are asked about to check whether a candidate understands the mechanism behind odd data behaviour. A strong answer explains the symptom through how the engine works: "the totals disagree because under Read Committed each query takes its own snapshot, and new orders committed between the queries."
Typical checks:
- OLTP versus OLAP, and why dashboards move to the warehouse.
- B-tree versus LSM on writes, point reads, and ranges.
- What the WAL is and how it feeds replicas and CDC.
- PostgreSQL isolation levels and a consistent multi-query report.
- Replica lag and query cancellation on a hot standby.
- A replication slot that fills the disk.
- Partition, sort key, and distribution key: what each lets the engine skip.
- Redistribution in an MPP join and skew across segments.
Common wrong answer: "Distribute the events table by date, so a one-day query reads one segment." In fact a distribution key only decides which segment holds a row and filters nothing. Distributing by date puts a whole day's work on one segment while the rest sit idle. Date pruning comes from elsewhere: date partitions in Greenplum, and in Redshift, which has no partitions, a compound sort key that starts with the date. You distribute by a key that spreads evenly and matches the join key, such as user_id.