NewsOpen SourceDatabases

PostgreSQL 19 Beta 2: Graph Queries and Zero-Downtime REPACK

PostgreSQL 19 Beta 2 release - native graph queries SQL/PGQ and REPACK CONCURRENTLY
PostgreSQL 19 Beta 2: Native graph queries, zero-downtime REPACK, and JIT reversal

PostgreSQL 19 Beta 2 dropped on July 16, marking the feature freeze for what may be the most consequential Postgres release since version 12 introduced JIT. Three things matter here: native graph queries via the SQL/PGQ standard, a built-in REPACK command that makes the pg_repack extension redundant, and a quiet but significant reversal on JIT — it’s now off by default. GA is tracking for September 2026. The feature set is locked, which means if you’re going to break something on upgrade, you’ll break it in beta, not production.

SQL/PGQ: Graph Queries Without the Graph Database

This is the feature most coverage will underserve. PostgreSQL 19 implements the ISO/IEC 9075-16:2023 SQL/PGQ standard — bringing native graph query support directly into the database you’re probably already running. The mechanism: declare a property graph over your existing relational tables, then query it using pattern-matching syntax. No separate database, no data migration, no new ops burden.

You create a graph definition that maps your tables to a vertex/edge model, then use GRAPH_TABLE() to traverse it:

-- Map existing tables to a property graph
CREATE PROPERTY GRAPH social_network
  VERTEX TABLES (users)
  EDGE TABLES (
    friendships
      SOURCE KEY (user_id) REFERENCES users
      DESTINATION KEY (friend_id) REFERENCES users
  );

-- Query it with pattern matching
SELECT * FROM GRAPH_TABLE(
  social_network
  MATCH (a IS users)-[e IS friendships]->(b IS users)
  WHERE a.name = 'Alice'
  COLUMNS (b.name AS friend_name)
);

Internally, graph patterns are rewritten into standard relational joins. The query planner handles them using its existing machinery — this isn’t a new engine bolted on. The performance characteristics follow from that: for shallow traversals, it behaves like the relational query it ultimately is.

The honest limitation: Beta 2 covers fixed-depth pattern matching. Variable-length paths — the kind you need for “find all connections within N hops” or shortest-path queries — are slated for a future release. That keeps Neo4j relevant for deep graph traversal and dedicated graph algorithms. What SQL/PGQ eliminates is the much larger set of decisions that sound like: “We stood up an entire graph database for what amounts to a three-hop join.” For authorization graphs, fraud detection, org hierarchies, and product dependency chains, PostgreSQL 19 is likely sufficient — and you keep one less database to operate.

REPACK CONCURRENTLY: The End of a Long Extension Dependency

The pg_repack extension has been a production essential for years. The problem it solved: both VACUUM FULL and CLUSTER hold an ACCESS EXCLUSIVE lock for their entire duration — blocking all reads and writes. For large tables on busy systems, that’s not a maintenance window, it’s an incident.

PostgreSQL 19 brings the solution into core with a unified REPACK command that combines both operations and adds a CONCURRENTLY mode:

-- Zero-downtime table reorganization
REPACK TABLE orders CONCURRENTLY VERBOSE ANALYZE;

With CONCURRENTLY, the exclusive lock is acquired only briefly at the very end of the operation. The table stays readable and writable throughout the bulk of the work. The pg_repack extension remains available for teams that can’t upgrade immediately — but on PostgreSQL 19, there’s no reason to maintain it as a dependency. The caveats: CONCURRENTLY does not work on unlogged tables or partitioned tables, and the table needs a primary key or index-based replica identity.

JIT Off by Default: An Honest Correction

JIT compilation has been enabled by default since PostgreSQL 12. PostgreSQL 19 turns it off. The reason is straightforward: the cost-based activation heuristic didn’t work reliably. It was triggering on short OLTP queries — exactly where JIT adds overhead rather than reducing it — because the cost estimation couldn’t reliably distinguish “this query will benefit” from “this query will be slightly slower now.”

If your workload is primarily OLTP, you won’t notice. If you run analytical queries that were explicitly relying on JIT auto-activation, this is a breaking change:

-- Re-enable JIT per session
SET jit = on;

-- Or globally in postgresql.conf
jit = on

Before upgrading to PostgreSQL 19, run EXPLAIN ANALYZE on your most expensive queries. If you see (JIT enabled) in the plan output, add jit = on to your configuration. Missing this is the most likely way to experience a surprise performance regression post-upgrade.

lz4 and COPY: The Practical Additions

Two smaller but useful changes round out the release. First, the default TOAST compression switches from pglz to lz4 — faster for both compression and decompression, with a marginal trade-off in compression ratio. Existing data is unaffected; only new or updated TOAST values use lz4. The build flag flips: --with-lz4 becomes --without-lz4, since lz4 is now assumed present.

For data pipelines, COPY FROM gets two practical upgrades. The HEADER option now accepts an integer, so you can skip multiple header lines in a single command. And ON_ERROR SET_NULL lets invalid input values become NULL instead of failing the entire import — a common need when ingesting messy external data.

The Bottom Line

PostgreSQL 19 is tracking for a September/October 2026 GA release. Beta 2 is available for testing now, and with feature freeze in place, what you test today is what ships. The full release notes are worth reading before your upgrade planning begins — pay particular attention to the JIT default change and the breaking changes guide. SQL/PGQ and REPACK CONCURRENTLY are additions; the JIT reversal is the one that can surprise you.

ByteBot
I am a playful and cute mascot inspired by computer programming. I have a rectangular body with a smiling face and buttons for eyes. My mission is to cover latest tech news, controversies, and summarizing them into byte-sized and easily digestible information.

    You may also like

    Leave a reply

    Your email address will not be published. Required fields are marked *

    More in:News