Pangram verdict · v3.3
We believe that this entire text is AI.
AI likelihood · overall
AIArticle text · 1,431 words · 10 segments analyzed
A release you can try at the prompt PostgreSQL 19 brings useful new SQL alongside maintenance and replication improvements. Try IGNORE NULLS, get-or-create inserts, JSON export, JSONPath transformations, and range subtraction, then explore planner advice and real replication. PostgreSQL 19.0 · released 19 November 2026. The stable release announcement introduces the version installed in this sandbox. Each feature links to its official documentation. The release notes remain the complete change log.
About this terminal.
Experiments run on a real PostgreSQL 19 server as student, in a disposable guest. Maintenance tables live in blog_lab. Replication experiments start additional real servers on demand: a logical subscriber on 5433, and a physical standby on 5434, both fed by the primary on 5432. To fit the guest’s memory budget, only one of these extra instances runs at a time: each replication card stops the other and starts its own. Re-run that card before checking its current state again. Their first runs take longer because they initialize a cluster or take a base backup. Reset discards all three clusters and their data. How to compare with 18. Sidenotes offer older SQL/workflows that you can run on 19, or a setting that disables a particular new optimization. These show the difference in expression or behavior. They do not turn PostgreSQL 19 into PostgreSQL 18. For timing claims, run the same workload on actual 18 and 19 servers with equal data, settings, cache conditions, and hardware. Run the experiments in any order. Commands beginning with \! run a shell command from psql. The logical replication walkthrough shows its server setup and SQL directly; as-postgres runs server utilities as the Linux postgres account. Query and comparison examples state when to use another port or the administrative SQL role.01Start with the server you actually haveBefore reading a release article, ask the server which release you are actually running. SELECT 1 is also a pleasantly boring connectivity test: a result beats a spinning status indicator. The version returned below belongs to the sandbox, not to the release covered by the article. The SQL role is student; ownership of the prepared demo database gives you room to experiment without administrative credentials. Look for: one row, a real server version, and the expected role. Keep that baseline when you compare an upgrade later.↳ TRY IT / CURRENT IMAGELive SQLFrom the shell, open the demo database (PGDATABASE=blog_lab):psqlThen run this at the SQL prompt:SELECT 1 AS terminal_is_alive, current_setting('server_version') AS actual_version, current_user AS sql_role;Expected: One row with terminal_is_alive = 1, the installed server version, and student.02REPACK — rewrite and reclaim spaceDeleting rows leaves reusable space behind. Regular vacuum cleans that space; PostgreSQL 19’s native REPACK rewrites the table and returns unused bytes to the OS. The card deletes middle rows, preserving occupied tail pages so ordinary vacuum cannot simply truncate them. Compare the file size after vacuum with its size after a real rewrite. The tiny table demonstrates the operation, not a storage benchmark. REPACK documentation. The concurrent variant uses logical decoding to capture intervening writes and takes an access-exclusive lock for the final swap. After the card, run this example at the same psql prompt. REPACK requires the table's MAINTAIN privilege; student owns events, so no role change is needed. REPACK (CONCURRENTLY, ANALYZE) events; Compare with 18: VACUUM (FULL, ANALYZE) events; performs the older blocking rewrite. For physical index ordering, compare CLUSTER events USING events_pkey; with REPACK events USING INDEX events_pkey;. Restore the same bloated table before each run. Use a second connection to try SELECT/INSERT while a larger rewrite runs, and inspect pg_locks: the concurrent form still locks briefly at the swap. PostgreSQL 18 has no native concurrent equivalent; the separately installed pg_repack extension is another workflow. ↳ TRY IT / CURRENT IMAGELive SQLDELETE FROM events WHERE id BETWEEN 301 AND 700;VACUUM (ANALYZE) events;SELECT pg_relation_size('events') AS bytes_before_repack;REPACK (ANALYZE) events;SELECT count(*) AS surviving_events, pg_relation_size('events') AS bytes_after_repack FROM events WHERE id <= 1000;Expected: DELETE 400 on the first run, VACUUM, REPACK, then 600 original surviving events. Compare bytes before/after; sizes vary.03Autovacuum — inspect the real priority scoresAutovacuum now prioritizes tables using real scores and can parallelize index work. The card reads pg_stat_autovacuum_scores and the configured score weights. Use \x on to show the wide scores view as readable records, then \x off to return to a table for the two-column settings query. Scores change with workload and statistics, so zero after maintenance is a useful result too. Autovacuum scheduling, statistics views. autovacuum_max_parallel_workers controls the server-wide allowance; autovacuum_parallel_workers is a per-table setting. The sandbox’s current parallel allowance is zero, so the card inspects priorities rather than launching parallel vacuum work. PostgreSQL 19 can also mark eligible pages all-visible during ordinary scans, improving future index-only scans. Compare with 18: On an administrative connection, set autovacuum_max_parallel_workers = 0 with ALTER SYSTEM, then reload using SELECT pg_reload_conf(); to disable this new parallel index work. Restore the previous value afterward. Manual VACUUM (PARALLEL 0) versus VACUUM (PARALLEL 2) is also runnable on 18, but measures manual vacuum. There is no faithful switch back to PostgreSQL 18’s autovacuum scheduler; compare the scheduling on separate installations. ↳ TRY IT / CURRENT IMAGELive SQL\x onSELECT * FROM pg_stat_autovacuum_scores WHERE relid IN ('events'::regclass, 'orders'::regclass);\x offSELECT name, setting FROM pg_settings WHERE name LIKE 'autovacuum%score_weight' OR name = 'autovacuum_max_parallel_workers' ORDER BY name;Expected: Expanded records for per-table scores, then a two-column table of configured weights; recently vacuumed tables may score zero.04Plan advice — constrain one query, then release itpg_plan_advice generates a description of planner choices and lets you constrain selected choices. pg_stash_advice stores advice by query identifier for automatic reuse. In this database setup has enabled the advice module for the student’s sessions; on another installation an administrator can use LOAD 'pg_plan_advice' or configure preloading. Plan advice, stored advice. The first plan emits generated advice; the second requests SEQ_SCAN(orders). Look for matched feedback. Advice restricts the normal planner and can become stale when data changes. Compare with 18: Run the settings, query, and resets in the same connection: SET enable_indexscan = off; SET enable_bitmapscan = off; EXPLAIN (ANALYZE, BUFFERS) SELECT sum(amount) FROM orders WHERE customer_id = 1; RESET enable_indexscan; RESET enable_bitmapscan; These broad settings discourage whole classes of paths. PostgreSQL 19’s advice can instead target a named table in a query. Our small table is likely to choose a sequential scan already; the interesting evidence is the advice and its feedback.↳ TRY IT / CURRENT IMAGELive SQLInspect the generated plan advice.EXPLAIN (PLAN_ADVICE, COSTS OFF) SELECT sum(amount) FROM orders WHERE customer_id = 1;Apply session advice, inspect the plan, then reset the setting.SET pg_plan_advice.advice = 'SEQ_SCAN(orders)'; EXPLAIN (ANALYZE, BUFFERS, COSTS OFF) SELECT sum(amount) FROM orders WHERE customer_id = 1; RESET pg_plan_advice.advice;Expected: Generated Plan Advice, then Supplied Plan Advice with matched feedback and an Aggregate plan.05Logical replication — see what moves between two serversFollow one row and one counter from source to destination. The publisher on 5432 owns the source data. The subscriber on 5433 is a separate PostgreSQL process with its own data directory. Both databases are named pg19_repl; the port identifies which one you are changing. ObjectPublisher · 5432Subscriber · 5433messagesWrite a rowThe publication copies the rowscratchWrite a rowExcluded from the publication; remains emptyticket_numbersConsume 50 valuesExplicit refresh copies the sequence state The commands below show the entire setup. Run them in order, or use Run all steps to enter the same visible commands.
\! runs a shell command from psql.
as-postgres runs the following command as the Linux postgres account; initdb initializes the cluster and pg_ctl starts it.
\connect database role host port chooses the SQL connection. Administrative SQL here explicitly uses the SQL role postgres. Local trust authentication is for this disposable guest.
The standby from experiment 06 is stopped first to fit the guest's memory budget. The subscriber uses small buffers and synchronous I/O for this runtime. Its log is /tmp/pg19-subscriber.log. Conditional setup preserves existing objects on repeat runs; each repeat advances the publisher counter again. What is new in 19? FOR ALL TABLES EXCEPT (TABLE scratch) excludes a table, and ALL SEQUENCES includes sequence state. Initial subscription creation copies sequence values; later publisher calls to nextval can leave the subscriber behind. REFRESH SEQUENCES requests another copy. We wait for the initial copy before advancing the publisher so it cannot mask the before/after comparison. The visible polling loops have a deadline because synchronization is asynchronous. Definitions must match on both servers.
Sequence synchronization, publication syntax.
The subscription receives data over loopback TCP; psql uses local Unix sockets for administration. Compare wal_level = replica with effective_wal_level = logical on the publisher after creating the publication: PostgreSQL 19 enables logical WAL when required without restarting this primary.
WAL configuration.