PostgreSQL 19's SQL/PGQ GRAPH_TABLE syntax is a parser-level rewriter that compiles graph queries into ordinary SQL joins against underlying tables. The regular query optimizer handles planning, meaning standard indexing rules apply. Forward traversal benefits from primary key indexes on source columns, while reverse traversal requires an explicit index on the destination column — adding one can yield ~20x speedup. Two-hop and multi-hop patterns expand into nested loop joins. Current limitations include no variable-length path patterns or shortest-path support, which can be worked around with WITH RECURSIVE. CREATE PROPERTY GRAPH is metadata-only, requiring no data migration on existing schemas.
Table of contents
SetupThe RewriteIndex Strategy: Forward vs Reverse TraversalWhat Does the Planner Do with Two Hops?What PostgreSQL 19 Does Not Have YetOperational ConsequencesTrying It Yourself1.6K Impressions