DataLane
← All stacks

PostgreSQL

The OLTP source: CDC, EXPLAIN, and do not scan prod

5 questions with solutions

  1. Q1StripeShopifyGitLab

    How should CDC read Postgres?

    Solution

    Logical decoding / a publication (Debezium or native), not polling updated_at. Monitor slot lag and disk. A slot nobody consumes is how the primary fills the disk.

  2. Q2AmazonGoogleMicrosoft

    A dashboard is slow. First tool?

    Solution

    EXPLAIN (ANALYZE, BUFFERS). Name seq scan vs index, then decide. Adding an index without a plan is cargo cult.

  3. Q3HerokuGitHubNotion

    Why is the table 10× the live rows?

    Solution

    Bloat. Dead tuples, delayed VACUUM, long transactions. Autovacuum is an SLO. “We will warehouse it” does not fix the primary.

  4. Q4Capital OnePayPalBlock

    Can Trino or the warehouse query the primary?

    Solution

    Not for BI. Replica or CDC copy. A federated scan of prod is an outage. Say this even if they did not ask.

  5. Q5SnowflakeDatabricksGoogle

    NULL in a unique column. What happens?

    Solution

    Postgres unique allows multiple NULLs (until NULLS NOT DISTINCT). Warehouse dialects differ. CDC + MERGE on a nullable key silently drops or dupes. Name the constraint.

↑↓ navigate openesc close