I'm always excited to take on new projects and collaborate with innovative minds.
PostgreSQL 19 Beta introduces SQL/PGQ, bringing property graph queries directly to PostgreSQL. Learn how it simplifies graph-like queries, replaces complex recursive CTEs for many use cases, and where it fits compared to native graph databases like Neo4j.
If you've ever written a recursive CTE in PostgreSQL, you probably remember two things:
Whether you're dealing with organization hierarchies, authorization models, dependency trees, or fraud detection, relational databases have always been capable of handling graph-like data—but the SQL wasn't exactly enjoyable.
That's changing with PostgreSQL 19 Beta.
PostgreSQL 19 introduces SQL/PGQ (Property Graph Queries), an ISO-standard way to query graph-shaped data directly inside PostgreSQL.
Instead of moving your data into a graph database, you define a property graph on top of your existing relational tables.
Think of it as a graph view built from tables you already have.
Once defined, you can query relationships using graph patterns instead of complicated recursive SQL.
One detail I found particularly interesting is that PostgreSQL isn't becoming a native graph database.
Graph queries are rewritten into regular SQL joins before execution.
That means:
It's a very PostgreSQL approach—adding new capabilities without changing the core architecture.
Not really.
Native graph databases still have a major advantage when it comes to deep or variable-length graph traversals over massive datasets.
PostgreSQL's implementation is designed for applications where graph relationships complement relational data—not replace it.
In other words:
Use SQL/PGQ when your application is mostly relational with some graph problems.
Use a graph database when your application is fundamentally graph-first.
I can see SQL/PGQ being useful for:
These are all scenarios where developers often end up writing recursive CTEs today.
I don't think PostgreSQL is trying to compete with Neo4j.
I think it's competing with the awkward SQL we've been writing for years.
For many backend developers, that's a much bigger win.
Will SQL/PGQ solve every graph problem?
No.
But if it helps us replace pages of recursive CTEs with cleaner, more expressive queries, PostgreSQL 19 will be an exciting release to watch.
What do you think? Is SQL/PGQ something you'd adopt, or would you still reach for a dedicated graph database?
Your email address will not be published. Required fields are marked *