Course
Data Engineering & Advanced SQL
Read real EXPLAIN plans, design indexes around operators and write cost, and build ETL on COPY, CDC, and MVCC-correct transactions.
Keep reading
Related articles from the SudoSecurity blog.
PostgreSQL 19 Is Out. REPACK Kept My Writes Running. The Docker Upgrade Will Stop Your App.
PostgreSQL 19 shipped on November 19 with REPACK (CONCURRENTLY), which removes table bloat without blocking writes. I measured it against VACUUM FULL, ran the upgrade from 18, and checked what breaks for self-hosters: Docker tags that refuse to start, a config setting that stops the server, and...
PostgreSQL Fixed 52 CVEs in One Release. The Upgrade Is the Easy Part.
PostgreSQL 18.7, 17.12, 16.16, 15.20 and 14.25 fix 52 security vulnerabilities, almost twice August's record of 28. The binary swap took under a second in my test. The post-update steps are where the work is, and one of them makes some indexes several times bigger.
What PostgreSQL 15 Changed
A new version of the popular open-source database PostgreSQL is now available, offering performance improvements over PostgreSQL 14 and new functions and capabilities for managing workloads in local and distributed deployments. Released on October 13 by the PostgreSQL Global Development Group,…
PHP API Performance: N+1 Queries, cURL, and Connection Pools
A PHP API case study: fixing an N+1 query, twenty serial cURL calls, missing connection pooling, and stats recalculated on every request with Redis caching.
Reviews
Enrolled members can rate this course.
No reviews yet.
The Engine Under the Query
How Postgres turns SQL text into a costed plan, and how to read what it decided.
- 01Your SQL Is a Specification, Not a PlanPostgres parses, rewrites, and cost-optimizes your SQL against pg_statistic — stale statistics are the real cause of most suddenly-slow plans.12mOpen
- 02Reading EXPLAIN Like a MechanicEXPLAIN (ANALYZE, BUFFERS) is a plan tree read inside-out, where estimated-versus-actual rows and hit-versus-read buffers point at the real problem.15mOpen
- 03What a Scan Actually CostsSeq scans beat index scans past a fraction of the table because random_page_cost prices heap fetches — tune it for NVMe and VACUUM for index-only scans.14mOpen
Indexing Strategy
B-tree, GIN, GiST, BRIN, composite ordering, and why every index is a write tax.
- 01B-tree Is Not Your Only IndexThe operator picks the index type: B-tree for ordering and equality, GIN for containment, GiST for overlap and exclusion constraints, BRIN for physically sorted time-series.15mOpen
- 02Composite Indexes and Column OrderComposite B-trees sort lexicographically — equality columns first, range last — and partial and expression indexes target the rows and spellings queries actually use.13mOpen
- 03Indexes Are Not FreeEvery index is a write tax on every INSERT and UPDATE; HOT updates, fillfactor, and per-table autovacuum tuning are how you control it.13mOpen
Analytical SQL
CTEs, window functions, grouping sets, and the time-series patterns that replace application code.
- 01CTEs and the Optimization FencePostgres 12+ inlines single-use CTEs, but MATERIALIZED still computes a shared intermediate once — and WITH RECURSIVE replaces N+1 hierarchy walks.14mOpen
- 02Window Functions Without the Self-JoinsWindow functions keep every row while ranking it inside its partition — the dedup, running-total, and latest-per-key patterns that end self-joins.15mOpen
- 03GROUP BY Beyond COUNT(*)GROUPING SETS, FILTER, and WITHIN GROUP aggregates compute pivots, subtotals, and exact percentiles in one scan instead of N queries.13mOpen
- 04Time-Series and Gap Analysisgenerate_series scaffolds the missing buckets, LAG plus a running SUM sessionizes gaps-and-islands, and timestamptz plus explicit zones keep reports honest.15mOpen
Moving Data: ETL in Production
COPY staging, incremental sync, replication slots, and the MVCC rules pipelines break.
- 01COPY, Staging, and Bulk LoadsCOPY into an UNLOGGED staging table, validate, merge with ON CONFLICT in one transaction — the bulk-load pattern that survives reruns.14mOpen
- 02Incremental Sync and Change Data CaptureWatermark syncs drop rows committed out of order and CDC replay is at-least-once — overlap, dedup, and watch pg_replication_slots before it eats the disk.16mOpen
- 03MVCC, Transactions, and Pipeline SafetyMVCC's snapshot rules make check-then-write a race; atomic UPDATEs, FOR UPDATE, retry loops on 40001/40P01, and short transactions keep pipelines correct.16mOpen