SQL/PGQ
SQL/PGQ is the property-graph query extension of SQL:2023. RushDB supports its
GRAPH_TABLE operator, which runs a graph pattern match and returns the
matches as a relational table that SQL can filter and sort. This page covers
the read-only profile RushDB implements. Use it when you want graph pattern
matching but prefer SQL syntax around it.
| Property | Value |
|---|---|
| Status | Stable (read-only) |
| Enabled | By default (languages.sql-pgq: true); a --languages list must name sql-pgq to keep it |
| Wire id | sqlPgq |
| Profile | SQL:2023 GRAPH_TABLE read profile |
| Implementation | Grafeo graph planner and executor |
| Access | read-only |
| Parameters | named ($name) |
| Transports | Protocol v1 (HTTP, gRPC) |
Note: SQL/PGQ is separate from relational SQL. Relational SQL sees labels as tables; SQL/PGQ sees the whole tenant as one property graph. SQL/PGQ statements are not available over the PostgreSQL wire protocol.
Data model mapping
The tenant is the graph. Node patterns match records by label; edge patterns
match relationships by type. Inside COLUMNS (...) you project node and edge
properties as output columns.
Supported features
| Feature | Example |
|---|---|
GRAPH_TABLE with MATCH | GRAPH_TABLE (MATCH (n:FACTION) COLUMNS (n.name AS name)) |
| Edge patterns | MATCH (p:Person)-[:KNOWS]->(f:Person) |
Projection with COLUMNS | COLUMNS (p.name AS source, f.name AS target) |
| Filtering on the result | ... AS g WHERE age >= 29 |
| Ordering on the result | ... AS g ORDER BY name DESC |
Examples
All nodes of a label:
SELECT * FROM GRAPH_TABLE (
MATCH (n:FACTION)
COLUMNS (n.name AS name)
) AS g
ORDER BY name
A relationship pattern:
SELECT * FROM GRAPH_TABLE (
MATCH (p:Person)-[:KNOWS]->(f:Person)
COLUMNS (p.name AS source, f.name AS target)
) AS g
Filter and sort the projected columns:
SELECT name FROM GRAPH_TABLE (
MATCH (p:Person)
COLUMNS (p.name AS name, p.age AS age)
) AS g
WHERE age >= 29
ORDER BY name DESC
Send it as a read:
{
"protocolVersion": 1,
"operation": {
"kind": "query",
"query": {
"kind": "statement",
"language": "sqlPgq",
"statement": "SELECT * FROM GRAPH_TABLE (MATCH (n:FACTION) COLUMNS (n.name AS name)) AS g ORDER BY name"
}
}
}
Limitations
- Read-only. The profile advertises
access: readOnlyand the limitationreadOnly. Sending a SQL/PGQ statement withmutate.statementfails withinvalid_request("SQL/PGQ is a read-only profile"), and SQL/PGQ statements cannot be staged in transactions. Write with Cypher, GQL, Gremlin, or SQL DML. - Only the features listed above are part of the profile. Joining a
GRAPH_TABLEresult with relational SQL tables is not supported; use relational SQL joins overrushdb_edgestables for that. - Results are materialized; there is no server-side cursor.