{"schema": "pgtrue.report/1", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c", "published": "2026-11-03T02:12:13Z", "publisher": "PostgresAI", "article": {"title": "The only scalable delete in Postgres is DROP TABLE \u2014 PlanetScale", "url": "https://planetscale.com/blog/the-only-scalable-delete", "date_published": "2026-06-11T00:00:00Z", "author": "Tom Pang", "publisher": "PlanetScale"}, "grade": "B+", "axes": [{"axis": "Factual", "summary": "A \u00b7 0 wrong of 17 checked \u00b7 0 caveats \u00b7 partly assessed"}, {"axis": "Applicable", "summary": "A \u00b7 0 checked \u00b7 partly assessed"}, {"axis": "Consistent", "summary": "A \u00b7 0 checked"}, {"axis": "Transparent", "summary": "A \u00b7 0 wrong of 10 checked \u00b7 0 caveats \u00b7 transparency: no answered defects \u00b7 partly assessed"}, {"axis": "Safe", "summary": "D \u00b7 2 wrong of 2 checked \u00b7 0 caveats \u00b7 partly assessed"}], "findings": [{"anchor": "F1", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F1", "claim": "\u2026mirror writes to a new table, then swap with an atomic rename\u2026", "title": "Renaming replacement tables leaves foreign keys attached to the original table", "explanation": "Foreign keys reference table OIDs in pg_constraint.h:96-97. RenameRelationInternal changes relname in tablecmds.c:4332-4334. Renaming two tables does not transfer those references. Existing foreign keys still target the original table after the name swap.", "verdict": "Dangerous", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L4332-L4334", "label": "REL_18_6 \u00b7 src/backend/commands/tablecmds.c:4332-4334"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/include/catalog/pg_constraint.h#L96-L97", "label": "REL_18_6 \u00b7 src/include/catalog/pg_constraint.h:96-97"}, {"url": "https://github.com/cybertec-postgresql/pg_squeeze/blob/400c5f6ae9bc911073a6824e9a19f4d475fb7331/pg_squeeze.c#L3193-L3195", "label": "pg_squeeze@REL1_9_4 \u00b7 pg_squeeze.c:3193-3195"}]}, {"anchor": "F3", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F3", "claim": "\u2026TRUNCATE big_table; INSERT INTO big_table SELECT * FROM temp_keep_big_table;\u2026", "title": "The cleanup can hide retained rows from older snapshots", "explanation": "TRUNCATE can make the table appear empty to older snapshots after commit. truncate.sgml:147-149 documents this behavior. Transactions that already accessed this table block truncation. Older snapshots from other work can survive the lock. Reinserting retained rows does not make them visible to those snapshots.", "verdict": "Dangerous", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ref/truncate.sgml#L120-L122", "label": "REL_18_6 \u00b7 doc/src/sgml/ref/truncate.sgml:120-122"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ref/truncate.sgml#L147-L149", "label": "REL_18_6 \u00b7 doc/src/sgml/ref/truncate.sgml:147-149"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/mvcc.sgml#L1840-L1844", "label": "REL_18_6 \u00b7 doc/src/sgml/mvcc.sgml:1840-1844"}]}, {"anchor": "F6", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F6", "claim": "Partitioning in Postgres is recursive\u2026", "title": "PostgreSQL 10 supports LIST, RANGE, and subpartitioning", "explanation": "PostgreSQL 10 supports LIST, RANGE, automatic insert routing, and subpartitioning. REL_10_0 ddl.sgml:2901-2915 documents these features. REL_18_6 ddl.sgml:4108-4114 also documents subpartitioning. Whole-partition deletion avoids bulk DELETE vacuum overhead at ddl.sgml:3997-4003.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ddl.sgml#L3997-L4003", "label": "REL_18_6 \u00b7 doc/src/sgml/ddl.sgml:3997-4003"}, {"url": "https://github.com/postgres/postgres/blob/5df0e99bea1c3e5fbffa7fbd0982da88ea149bb6/doc/src/sgml/ddl.sgml#L2901-L2906", "label": "REL_10_0 \u00b7 doc/src/sgml/ddl.sgml:2901-2906"}, {"url": "https://github.com/postgres/postgres/blob/5df0e99bea1c3e5fbffa7fbd0982da88ea149bb6/doc/src/sgml/ddl.sgml#L2910-L2915", "label": "REL_10_0 \u00b7 doc/src/sgml/ddl.sgml:2910-2915"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ddl.sgml#L4108-L4114", "label": "REL_18_6 \u00b7 doc/src/sgml/ddl.sgml:4108-4114"}]}, {"anchor": "F7", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F7", "claim": "\u2026When rows mutate, Postgres can maintain multiple versions of the same row\u2026", "title": "DELETE retains row versions for later cleanup", "explanation": "DELETE records transaction metadata in the heap tuple at heapam.c:3123-3130. It leaves physical cleanup for later. maintenance.sgml:169-174 documents reusable space and the limited tail-page exception for returning space to the operating system.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/access/heap/heapam.c#L3123-L3130", "label": "REL_18_6 \u00b7 src/backend/access/heap/heapam.c:3123-3130"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/maintenance.sgml#L169-L174", "label": "REL_18_6 \u00b7 doc/src/sgml/maintenance.sgml:169-174"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/mvcc.sgml#L42-L47", "label": "REL_18_6 \u00b7 doc/src/sgml/mvcc.sgml:42-47"}]}, {"anchor": "F8", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F8", "claim": "\u2026an index scan that finds a dead row can mark the entry as dead itself.", "title": "Index scans can mark entries dead after checking the heap", "explanation": "DELETE defers index-tuple removal to vacuum in nodeModifyTable.c:1807-1809. indexam.c:692-699 requests dead-entry marking after finding an entirely dead HOT chain. Recovery scans skip this optimization.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/executor/nodeModifyTable.c#L1808-L1809", "label": "REL_18_6 \u00b7 src/backend/executor/nodeModifyTable.c:1808-1809"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/access/index/indexam.c#L692-L699", "label": "REL_18_6 \u00b7 src/backend/access/index/indexam.c:692-699"}]}, {"anchor": "F9", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F9", "claim": "\u2026DROP TABLE and TRUNCATE require a heavyweight AccessExclusiveLock\u2026", "title": "DROP TABLE and TRUNCATE take ACCESS EXCLUSIVE locks", "explanation": "RemoveRelations initializes AccessExclusiveLock at tablecmds.c:1553. truncate.sgml:111-114 documents the same lock for TRUNCATE. The lock blocks concurrent operations on each affected table.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L1553-L1553", "label": "REL_18_6 \u00b7 src/backend/commands/tablecmds.c:1553-1553"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ref/truncate.sgml#L111-L114", "label": "REL_18_6 \u00b7 doc/src/sgml/ref/truncate.sgml:111-114"}]}, {"anchor": "F10", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F10", "claim": "\u2026CREATE TEMP TABLE temp_keep_big_table AS SELECT * FROM big_table WHERE updated_at >= '2026-04-01'\u2026", "title": "CREATE TEMP TABLE AS copies the selected retained rows", "explanation": "CREATE TABLE AS copies SELECT output once. create_table_as.sgml:39-44 documents the resulting column names and types. The displayed cutoff keeps rows whose compatible updated_at value meets the comparison. This checks statement structure and semantics, not the unknown table schema.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ref/create_table_as.sgml#L39-L44", "label": "REL_18_6 \u00b7 doc/src/sgml/ref/create_table_as.sgml:39-44"}]}, {"anchor": "F11", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F11", "claim": "pg_squeeze is for optimizing tables that already have significant bloat.", "title": "pg_squeeze reclaims unused table space through an online rewrite", "explanation": "pg_squeeze README.md:1-4 describes concurrent space reclamation. Lines 17-18 specify logical decoding for concurrent changes. pg_squeeze.c:3193-3195 swaps physical storage identifiers. The article's broad online-rewrite analogy holds, but these mechanisms differ from trigger capture and table-name swaps.", "verdict": "Accurate", "sources": [{"url": "https://github.com/cybertec-postgresql/pg_squeeze/blob/400c5f6ae9bc911073a6824e9a19f4d475fb7331/README.md#L1-L4", "label": "pg_squeeze@REL1_9_4 \u00b7 README.md:1-4"}, {"url": "https://github.com/cybertec-postgresql/pg_squeeze/blob/400c5f6ae9bc911073a6824e9a19f4d475fb7331/README.md#L17-L18", "label": "pg_squeeze@REL1_9_4 \u00b7 README.md:17-18"}, {"url": "https://github.com/cybertec-postgresql/pg_squeeze/blob/400c5f6ae9bc911073a6824e9a19f4d475fb7331/pg_squeeze.c#L3193-L3195", "label": "pg_squeeze@REL1_9_4 \u00b7 pg_squeeze.c:3193-3195"}, {"url": "https://github.com/cybertec-postgresql/pg_squeeze/blob/400c5f6ae9bc911073a6824e9a19f4d475fb7331/README.md#L1-L4", "label": "pg_squeeze@REL1_9_4 \u00b7 README.md:1-4"}, {"url": "https://github.com/cybertec-postgresql/pg_squeeze/blob/400c5f6ae9bc911073a6824e9a19f4d475fb7331/README.md#L16-L18", "label": "pg_squeeze@REL1_9_4 \u00b7 README.md:16-18"}]}, {"anchor": "F12", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F12", "claim": "\u2026Since version 10, Postgres has had great partitioning support.", "title": "PostgreSQL 10 supports the described partitioning methods", "explanation": "PostgreSQL 10 supports declarative RANGE and LIST partitioning. REL_10_0 doc/src/sgml/release-10.sgml:1595 confirms both methods. doc/src/sgml/ddl.sgml:3104 documents subpartitioning.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/5df0e99bea1c3e5fbffa7fbd0982da88ea149bb6/doc/src/sgml/release-10.sgml#L1595-L1595", "label": "REL_10_0 \u00b7 doc/src/sgml/release-10.sgml:1595-1595"}, {"url": "https://github.com/postgres/postgres/blob/5df0e99bea1c3e5fbffa7fbd0982da88ea149bb6/doc/src/sgml/ddl.sgml#L3104-L3106", "label": "REL_10_0 \u00b7 doc/src/sgml/ddl.sgml:3104-3106"}]}, {"anchor": "F13", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F13", "claim": "\u2026big batch DELETE operations don't immediately free up physical disk space\u2026", "title": "DELETE does not immediately reclaim deleted row storage", "explanation": "DELETE retains old row versions until cleanup can reclaim them. REL_18_6 doc/src/sgml/maintenance.sgml:157 states that DELETE does not immediately remove the old row version.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/maintenance.sgml#L157-L158", "label": "REL_18_6 \u00b7 doc/src/sgml/maintenance.sgml:157-158"}]}, {"anchor": "F14", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F14", "claim": "VACUUM FULL allows for this, but takes an expensive lock for a long time.", "title": "VACUUM FULL rewrites the table under ACCESS EXCLUSIVE", "explanation": "VACUUM FULL compacts the table through a file rewrite. REL_18_6 doc/src/sgml/maintenance.sgml:131 documents ACCESS EXCLUSIVE locking. The rewrite can take substantial time.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/maintenance.sgml#L131-L134", "label": "REL_18_6 \u00b7 doc/src/sgml/maintenance.sgml:131-134"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/maintenance.sgml#L174-L176", "label": "REL_18_6 \u00b7 doc/src/sgml/maintenance.sgml:174-176"}]}, {"anchor": "F15", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F15", "claim": "\u2026using foreign keys and CASCADE for deletions can cause a single row delete to delete gigabytes of data\u2026", "title": "One parent-row deletion can cascade to many child rows", "explanation": "ON DELETE CASCADE automatically deletes referencing rows. REL_18_6 doc/src/sgml/ddl.sgml:1294 documents that behavior. A large collection of referencing rows can occupy gigabytes.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ddl.sgml#L1294-L1295", "label": "REL_18_6 \u00b7 doc/src/sgml/ddl.sgml:1294-1295"}]}, {"anchor": "F16", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F16", "claim": "\u2026a workload that does \"lots of DELETE \" into a workload that does \"occasional DROP TABLE .\"\u2026", "title": "Partition removal avoids deleting each expired row", "explanation": "Dropping an expired partition avoids individual row deletion. REL_18_6 doc/src/sgml/ddl.sgml:4324 documents this advantage and the parent-table lock. TRUNCATE also avoids scanning table rows.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ddl.sgml#L4324-L4327", "label": "REL_18_6 \u00b7 doc/src/sgml/ddl.sgml:4324-4327"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ref/truncate.sgml#L33-L38", "label": "REL_18_6 \u00b7 doc/src/sgml/ref/truncate.sgml:33-38"}]}, {"anchor": "F17", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F17", "claim": "\u2026this prevents other transactions from reading or writing the table\u2026", "title": "ACCESS EXCLUSIVE blocks concurrent table access", "explanation": "ACCESS EXCLUSIVE blocks other concurrent operations on the table. REL_18_6 doc/src/sgml/ref/truncate.sgml:111 documents the same lock and its blocking behavior.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ref/truncate.sgml#L111-L113", "label": "REL_18_6 \u00b7 doc/src/sgml/ref/truncate.sgml:111-113"}]}, {"anchor": "F18", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F18", "claim": "\u2026different transactions can see row values as of the time they were queried\u2026", "title": "Read Committed queries can observe different snapshots", "explanation": "Read Committed SELECT queries observe committed data from their query-start snapshots. REL_18_6 doc/src/sgml/mvcc.sgml:324 documents this behavior.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/mvcc.sgml#L324-L326", "label": "REL_18_6 \u00b7 doc/src/sgml/mvcc.sgml:324-326"}]}, {"anchor": "F19", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F19", "claim": "\u2026(a BufferDesc , padded to 64 bytes) for every 8KB buffer\u2026", "title": "64-byte shared buffer descriptors match the default 8 KiB page calculation", "explanation": "PostgreSQL pads shared buffer descriptors to 64 bytes on ordinary 64-bit builds. configure.ac:253 defaults pages to 8,192 bytes. src/backend/storage/buffer/buf_init.c:78 allocates one padded descriptor per buffer.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/include/storage/buf_internals.h#L293-L293", "label": "REL_18_6 \u00b7 src/include/storage/buf_internals.h:293-293"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/configure.ac#L253-L260", "label": "REL_18_6 \u00b7 configure.ac:253-260"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/buffer/buf_init.c#L78-L78", "label": "REL_18_6 \u00b7 src/backend/storage/buffer/buf_init.c:78-78"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/buffer/buf_init.c#L85-L85", "label": "REL_18_6 \u00b7 src/backend/storage/buffer/buf_init.c:85-85"}]}, {"anchor": "F20", "url": "https://pgtrue.postgres.ai/shared/brief/ba676115-b32d-46ee-84e8-c21330a8981c#F20", "claim": "\u2026with 128GB of shared buffers, you are sweeping only ~1GB of memory, sequentially\u2026", "title": "128 GiB of default buffers has approximately 1 GiB of descriptors", "explanation": "Descriptors occupy 1/128 of buffer storage (derived: 64 bytes / 8,192 bytes). A 128 GiB pool has approximately 1 GiB of descriptors. src/backend/storage/buffer/bufmgr.c:4791 walks descriptors sequentially in its full-scan branch. An optimization can avoid that scan.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/include/storage/buf_internals.h#L293-L293", "label": "REL_18_6 \u00b7 src/include/storage/buf_internals.h:293-293"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/configure.ac#L253-L260", "label": "REL_18_6 \u00b7 configure.ac:253-260"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/buffer/buf_init.c#L78-L78", "label": "REL_18_6 \u00b7 src/backend/storage/buffer/buf_init.c:78-78"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/buffer/buf_init.c#L85-L85", "label": "REL_18_6 \u00b7 src/backend/storage/buffer/buf_init.c:85-85"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/buffer/bufmgr.c#L4791-L4795", "label": "REL_18_6 \u00b7 src/backend/storage/buffer/bufmgr.c:4791-4795"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/buffer/bufmgr.c#L4724-L4727", "label": "REL_18_6 \u00b7 src/backend/storage/buffer/bufmgr.c:4724-4727"}]}]}