Skip to content
  1. Planet PostgreSQLGuides & Cases

    Deepak Mahto: Exploring PostgreSQL 19 – Part 2: SELECT expression INTO in PL/pgSQL

    PostgreSQL 19 closes the performance gap between SELECT expr INTO v and v := expr in PL/pgSQL, which was roughly 5x slower before. A 1,000,000-iteration benchmark on PostgreSQL 18 took 201.

    Brief · Based on the source excerpt

    Test conditionsMigrated Oracle and SQL Server PL/pgSQL code gains speed without rewrites; after upgrading to PostgreSQL 19, re-benchmark loop-heavy procedures that rely on SELECT ... INTO.

  2. Planet PostgreSQLGuides & Cases

    PostgreSQL 19 REPACK (CONCURRENTLY) in Practice: Reads and Writes Continue, but the Final Swap Still Waits on Locks

    PostgreSQL 19's REPACK (CONCURRENTLY) allowed reads and writes during the main rewrite, but the final table swap had to wait for an open read transaction to release its lock, so the operation is not fully lock-free. In the test, a regular VACUUM left the table at 70 MB while REPACK reduced it to 14 MB.

    Brief · Based on the source excerpt

    Why It MattersUse REPACK (CONCURRENTLY) to reclaim disk space from bloated tables without a full outage, but budget for the final ACCESS EXCLUSIVE swap and avoid long-running transactions; validate in a test database first.

  3. select * from depesz;Guides & Cases

    How PostgreSQL 19 Handles INSERT … ON CONFLICT DO SELECT

    PostgreSQL 19’s INSERT … ON CONFLICT DO SELECT inserts new rows or returns existing ones on conflict without a no-op update. It requires RETURNING and supports optional row locking. When locking is requested, conflicting rows filtered out by WHERE are still locked.

    Why It MattersWhen replacing no-op updates in get-or-create code, check whether the old primary key is null to identify inserts, since the command tag counts returned rows.

  4. Planet PostgreSQLGuides & Cases

    Routine OS Patching Broke PostgreSQL Backups by Mismatching pgBackRest Versions

    Routine OS patching upgraded pgBackRest on the production PostgreSQL server from 2.55.1 to 2.59.3 but left the backup server on 2.55.1, causing the next morning’s backup to fail. There was no downtime or data loss, but for several hours the newest backup was more than a day old.

    Brief · Based on the source excerpt

    Why It MattersWith a separate backup server, locking pgBackRest versions and checking both hosts after patching can reduce the risk of backup failure.

  5. select * from depesz;Guides & Cases

    Testing PostgreSQL 19’s Slot-Driven Logical Decoding

    Tests show PostgreSQL 19 enables logical decoding without a restart when the first logical slot is created with wal_level=replica. The checkpointer reverts to replica asynchronously after the last slot is dropped or invalidated. effective_wal_level shows the current level.

    Why It MattersEnabling logical decoding for on demand CDC no longer requires a restart, but leftover valid logical slots can keep the extra WAL overhead in place.

  6. Neon BlogGuides & Cases

    Building a Software Factory on Neon

    Neon runs several agent pipelines that turn Slack requests, GitHub issues and alerts into reviewed PRs, keeping orchestrator state in Postgres and giving each request its own branch of the production database.

    Why It MattersIsolating each request in a branch of production and keeping process control in plain code lets agents change data without touching production or colliding; the cost is maintaining orchestrator state tables plus branch expiration and snapshot policies.

  7. Planet PostgreSQLGuides & Cases

    PostgreSQL 19 DBA Walkthrough, Part 2: Read Your Writes with WAIT FOR LSN

    A two-session psql walkthrough shows how PostgreSQL 19 uses WAIT FOR LSN to read your writes on an asynchronous standby. It captures the WAL insert LSN on the same primary connection after commit and also covers timeouts, monitoring waiters, and a stalled standby.

    Brief · Based on the source excerpt

    Why It MattersWhen reads from an asynchronous standby must reflect a just committed write, the application can wait before reporting success without adding that wait to the primary’s synchronous commit path.

  8. Crunchy DataGuides & Cases

    Queries captured by pg_stat_statements can be re-run from psql by passing arguments with the \bind command when they are simple SELECT statements. Statements with IN lists don't work because pg_stat_statements collapses them; use EXPLAIN (GENERIC_PLAN) instead.

    Why It MattersThe approach works for parameterized replay of simple SELECTs sampled from pg_stat_statements; statements with IN lists must fall back to EXPLAIN (GENERIC_PLAN) since their parameters can't be matched.

  9. Lobste.rs DatabasesGuides & Cases

    Giving AI Agents Safe Access to PostgreSQL: Read-Only Roles, Temporary Credentials and Query Logging

    Restricting an AI agent to a read-only PostgreSQL role, read-only transactions or a read replica limits writes, but permissions are additive and PUBLIC grants can still allow updates.

    Why It MattersAdopting this requires automating credential provisioning and cleanup, and explicitly terminating existing sessions when access ends, since expired passwords do not close open connections.

  10. Planet PostgreSQLGuides & Cases

    Umair Shahid: How a 40 TB PostgreSQL Cutover Took One Night

    Umair Shahid recounts a regulated payments company's cutover of more than 40 TB of production data to a new EDB Postgres cluster, starting at 2 AM and back online by morning with all post-cutover validation checks confirmed in writing.

    Brief · Based on the source excerpt

    Why It MattersFor large migrations, size the timeline from the largest tables rather than total volume, and use replication against a live source to compress downtime into a single overnight cutover window.

  11. Percona PostgreSQL BlogGuides & Cases

    How PostgreSQL 19’s WAIT FOR LSN Can Replace Synchronous Replication

    PostgreSQL 19’s WAIT FOR LSN lets apps wait after commit for a standby flush or replay, for durability on both servers or read-your-writes. A timeout leaves the outcome unknown. Percona’s author recommends waiting for 19.1 before production use because 19.0 lacks a critical fix.

    Why It MattersWaiting on demand keeps standby outages from stalling primary commits, but standby connection pools need capacity for sessions held open while they wait.

  12. Planet PostgreSQLGuides & Cases

    PostgreSQL 19 Developer Guide: Returning Existing Rows with INSERT ON CONFLICT DO SELECT

    PostgreSQL 19’s INSERT … ON CONFLICT DO SELECT returns the existing row on a unique key conflict. A registration example shows why DO NOTHING RETURNING yields no row on conflict and why DO UPDATE returns one only by rewriting it.

    Brief · Based on the source excerpt

    Why It MattersFor get or create operations keyed by a unique value, returning the existing row on conflict avoids both an extra database round trip and a rewrite just to retrieve the row.

  13. Hacker News PostgreSQLGuides & Cases

    What Changes When You Upgrade from PostgreSQL 18 to 19

    In PostgreSQL 18.6 vs 19.0 tests, median time fell from 202.0 to 119.0 ms for a 100,000-row foreign-key insert and from 51.1 to 38.6 ms for NOT IN counting 250,000 missing IDs. Native REPACK (CONCURRENTLY) allows reads and writes during the rewrite but needs an ACCESS EXCLUSIVE lock for the final swap.

    Why It MattersNative concurrent REPACK can replace some scheduled pg_repack jobs, but the decision depends on how long the final swap waits for an exclusive lock under production traffic.

  14. Lobste.rs DatabasesGuides & Cases

    ClickHouse Tests PostgreSQL 19 pg_plan_advice and Its Hazards

    ClickHouse tests PostgreSQL 19’s pg_plan_advice and pg_stash_advice on ClickHouse Managed Postgres, using scan and JOIN-order hints to address planner misestimates.

    Why It MattersUsing ClickHouse Managed Postgres tests, the article shows where PostgreSQL 19 plan advice helps and how stale or poor advice can degrade query performance.

  15. Planet PostgreSQLGuides & Cases

    How PostgreSQL Orders Memory Accesses with Barriers, Volatile, and Atomics

    Jan Kristof Nidzwetzki explains PostgreSQL's memory and compiler barrier macros such as pg_memory_barrier(), pg_write_barrier(), pg_read_barrier(), and pg_compiler_barrier(), and why they are needed to stop compiler and CPU reordering from breaking shared-memory code.

    Brief · Based on the source excerpt

    Why It MattersShared-memory code that has long worked on x86 can fail on ARM, so its ordering assumptions need to be checked against the target platform’s memory model.

  16. Planet PostgreSQLGuides & Cases

    Umair Shahid: Where 39% of the WAL Came From

    Umair Shahid breaks down a Supabase customer case writing 1. 8 TB of WAL per day, where about 39% was full-page-image overhead caused by the five-minute checkpoint_timeout default.

    Brief · Based on the source excerpt

    Why It MattersFor workloads that frequently modify hot tables and indexes, check whether repeated checkpoints are inflating WAL through full-page images rather than disabling the full-page writes that protect against torn pages.

  17. CYBERTEC PostgreSQL BlogGuides & Cases

    How to Deal with Slow Shutdown in PostgreSQL

    Laurenz Albe explains why PostgreSQL shutdown can be slow: a clean shutdown runs a checkpoint that flushes dirty shared buffers to disk, so larger shared_buffers and more dirty pages mean longer shutdown.

    Why It MattersFor PostgreSQL instances needing fast restarts, an explicit CHECKPOINT before shutdown shortens downtime; with large UNLOGGED tables you must use FLUSH_UNLOGGED (v19+) or the FILE_COPY database trick, or shutdown stays slow.

  18. Planet PostgreSQLGuides & Cases

    PostgreSQL 19 Plan Advice Tools for Transactional Outbox Workloads

    A lab using the transactional outbox pattern shows how changed data and stale statistics can lead PostgreSQL to choose an execution plan based on outdated information. It introduces PostgreSQL 19’s pg_plan_advice and pg_stash_advice, including generated advice for reproducing an index scan plan.

    Brief · Based on the source excerpt

    Why It MattersThe lab shows how stale statistics can mislead PostgreSQL’s planner on transactional outbox workloads and introduces PostgreSQL 19 tools for reproducing and stashing plan advice.

  19. Planet PostgreSQLGuides & Cases

    Vibhor Kumar: Relevance Is Not Permission — Filter-First Vector Search in PostgreSQL

    Vibhor Kumar argues in a Planet PostgreSQL post that permission checks must live in PostgreSQL SQL rather than in application-side filtering after vector retrieval.

    Brief · Based on the source excerpt

    Why It MattersMaking access control a property of the data reduces the risk that autonomous agents omit permission checks, while filtering still needs to preserve enough candidates.

  20. Planet PostgreSQLGuides & Cases

    Álvaro Herrera: Squeezing Tables with Postgres 19

    Álvaro Herrera discusses table compaction in Postgres 19 and why VACUUM FULL was not enough. He opens with a question Pavel Stehule raised on the hackers mailing list in January 2024: why isn’t there a VACUUM FULL CONCURRENTLY?

    Author Álvaro Herrera · Original article

    Brief · Based on the source excerpt

    Why It MattersFor very large, high-velocity databases, managing table bloat is about both compacting tables and doing so while the workload continues.

  21. CYBERTEC PostgreSQL BlogGuides & Cases

    How to Stabilize Query Plans in PostgreSQL 19 with pg_stash_advice

    PostgreSQL 19 uses pg_plan_advice and pg_stash_advice to constrain join order without rewriting SQL. In the example, a row estimate of 20 versus 990 led to a 405.646 ms query. Stored advice survives restarts but not pg_upgrade. cybertec-postgresql.com/en/pg…

    Why It MattersConstraining only the join order can guard against a bad choice caused by underestimated row counts while leaving the planner free to adapt join methods and scan strategies.

  22. Planet PostgreSQLGuides & Cases

    How PostgreSQL Continuously Tests Security Patches Before Disclosure

    Since June 2026, PostgreSQL has managed pending security patches in the private pgsql-security Git repository and continuously built and tested them across all supported branches in a private buildfarm. Each branch has an ordered patch list and can reference patches shared with other branches.

    Brief · Based on the source excerpt

    Why It MattersThe workflow offers a practical way to move cross-platform builds and tests from release packaging day into routine development without disclosing security patches.

  23. Planet PostgreSQLGuides & Cases

    How to Build PostgreSQL Extension RPM and DEB Packages with PGRX 0.20

    With PGRX 0.20, cargo pgrx package builds PostgreSQL extension RPM and DEB packages directly on Linux without a spec file, debian/ directory, or extra tools. It supports Postgres 15–19 and adds cargo pgrx migrate to assemble upgrade scripts from SQL fragments.

    Author Damien Clochard · Original article

    Brief · Based on the source excerpt

    Why It MattersThe comparison between generating a directory tree and building packages directly shows extension maintainers which manual steps they can skip when packaging for multiple distributions.

  24. Postgres.fmGuides & Cases

    Postgres.fm Breaks Down the Hidden Costs of CREATE TEMP TABLE

    Postgres. fm episode 193 examines the hidden costs of CREATE TEMP TABLE: dead tuples, catalog bloat, and the shared invalidation queue every session must read.

    Why It MattersWhen temporary tables are repeatedly created and dropped in the request path, distinguish baseline catalog churn from shared invalidation lock contention amplified by many idle sessions.

  25. Percona PostgreSQL BlogGuides & Cases

    Percona Maps How glibc Changes Can Break PostgreSQL Clusters

    Percona compares PostgreSQL clusters on Rocky Linux 8. 9 and 9. 3 using the sv_SE locale, showing that glibc changes can affect indexes, constraints, partitions, generated columns, materialized views, and query results.

    Why It MattersThe article maps how glibc locale changes affect indexes, constraints, partitions, and stored results, showing why REINDEX alone is insufficient.

  26. pganalyze BlogGuides & Cases

    Postgres in Production, Part 6: Diagnosing High Cardinality Workloads in pg_stat_statements

    Part 6 of pganalyze's Postgres in Production series explains how to tell whether a workload is generating more unique normalized queries than pg_stat_statements.

    Why It MattersFor workloads that frequently generate variable-length IN lists, upgrading to PostgreSQL 18 can reduce statement entry usage through normalization, leaving room for other queries’ tuning metrics.

  27. Haki Benita BlogGuides & Cases

    How to Prune PostgreSQL Partitions When Filtering on Non-Partition Key Columns

    Haki Benita demonstrates how PostgreSQL can prune partitions when filtering on non-partition key columns if the data follows certain patterns. In a table partitioned by timestamp, local indexes let a query filtering on session_id avoid sequential scans, but it still visits every partition.

    Why It MattersWhen session IDs correlate strongly with event time and historical partitions no longer change, CHECK constraints can skip irrelevant partitions without changing the time-based partition key.

  28. Haki Benita BlogGuides & Cases

    Why Row Locks Can Produce Surprising Join Results in PostgreSQL

    In PostgreSQL, an inner join waiting for a row lock can return no rows if another transaction updates the foreign key and commits, even though the foreign key constraint is enforced.

    Why It MattersAt Read Committed, transactions that validate the current foreign-key relationship can lock the referencing row before looking up the related row, rather than relying on a join formed before the lock wait.

  29. Haki Benita BlogGuides & Cases

    Unconventional PostgreSQL Optimizations

    Haki Benita explores unconventional PostgreSQL techniques: using CHECK constraints to skip full table scans, using function-based indexes to lower cardinality, and enforcing uniqueness with a hash index.

    Why It MattersFor long text that only needs equality lookups and is not referenced by foreign keys, a hash-backed exclusion constraint can save index space but cannot support ON CONFLICT DO UPDATE.