PostgreSQL 19 introduces SQL/PGQ support for property graphs, and this post dives into heterogeneous graphs with multiple vertex and edge types. Using a social+work dataset (persons, companies, knows, works_at), it demonstrates how to define a multi-label property graph and write GRAPH_TABLE queries spanning different node types. Key topics include: traversing mixed-type paths (person→person→company), a workaround for PostgreSQL 19's lack of comma-separated MATCH patterns (join two GRAPH_TABLE results instead), the pitfall of anonymous edge patterns in multi-label graphs (they match all edge types via an Append plan), and the current limitation around quantified path hops ({1,3} syntax not yet supported).

8m read timeFrom cybertec-postgresql.com
Post cover image
Table of contents
Loading sample data for graphsCreating more complex graphs in PostgreSQLTwo coworkers who know each otherCommon outfalls in SQL/PGQFinally …
1.1K Impressions