# Exploring SQL/PGQ graph querying in PostgreSQL

> **Key takeaway:** The SQL/PGQ standard allows defining property graphs over existing relational tables to enable pattern-based querying.

**Published:** 2026-10-21T00:00:00+00:00 
**Source:** Planet PostgreSQL 
**Category:** databases-storage 
**Canonical URL:** https://fosswire.org/news/exploring-sqlpgq-graph-querying-in-postgresql.html 

## Summary
A technical deep dive explores how PostgreSQL can function as a graph database using the SQL/PGQ extension from the SQL:2023 standard. The article compares traditional recursive SQL queries with the more concise pattern-matching syntax of SQL/PGQ. It also discusses the implementation status and the complexities of modeling graph structures like shortest paths and trails within a relational engine.

## SQL vs. SQL/PGQ for graph patterns
- **SQL/PGQ** is an extension of the SQL:2023 standard that enables property graph definitions over existing tables.
- Traditional SQL requires **WITH RECURSIVE** and manual bookkeeping (like tracking paths in arrays to avoid cycles) for multi-hop queries.
- SQL/PGQ uses a **GRAPH_TABLE** syntax with pattern matching similar to **Cypher**.
- The implementation in PostgreSQL has faced challenges, leading to previous reverts, with further features still in development.

## Why it matters
As SQL/PGQ moves toward standardization, PostgreSQL users may gain native graph capabilities without migrating to specialized graph databases.