Skip navigation

Exploring property graphs with SQL/PGQ in PostgreSQL

Ashutosh Bapat

Ashutosh Bapat Ashutosh Bapat

(Livestream 4)

Using relational databases, how do you efficiently determine an optimal path covering all your tickets in the game of Ticket to Ride? Traditionally, solutions to graph-like problems in PostgreSQL—such as reachability and shortest-path discovery—have relied on Recursive Common Table Expressions (CTEs), which are often verbose, difficult to optimize, and complex to maintain. The SQL:2023 standard introduces SQL/PGQ (Property Graph Queries), finally allowing a relational database like PostgreSQL to treat graph traversals as first-class, declarative operations. And we are working to bring SQL/PGQ support to a future release of PostgreSQL, hopefully in PostgreSQL 19!

In this session, you will explore property graph (SQL/PGQ) capabilities using the Ticket to Ride—like schema as a practical example. You will learn important aspects of SQL/PGQ: from defining a Property Graph over standard relational tables to using MATCH clause to implement pathfinding logic.

Beyond the game, the session provides an under the hood look at the SQL/PGQ implementation in Postgres. The transformation of graph patterns into relational join trees and the complexities of path-variable bindings will be discussed. You will leave with a clear understanding of the Postgres implementation of the SQL/PGQ standard from one of the authors of the patch himself.

talk bubbles
Join the conversation

Use the hashtag #PosetteConf