SQL Reference

NodeDB exposes a PostgreSQL-compatible SQL surface over pgwire, HTTP, and the native protocol. All features below are available in every deployment mode (Origin cloud, Origin local, NodeDB-Lite where noted).

Core SQL

PageWhat it covers
OverviewQuery execution model, PG compatibility basics, isolation level
DDLCollections, indexes, triggers, functions, materialized views, cron, backup
SELECTFiltering, aggregates, window functions, CTEs, recursive CTEs, set operations
INSERT & UPSERTINSERT, ON CONFLICT, UPSERT, COPY FROM
UPDATE & DELETEUPDATE, UPDATE … FROM, DELETE, RETURNING, MERGE, transactions
JOINs & AggregationsInner/outer/semi/anti joins, LATERAL, GROUP BY ROLLUP/CUBE/GROUPING SETS
FunctionsScalar, aggregate, date/time, KV atomic, timeseries, vector, FTS, CRDT

Engine-Specific SQL

PageWhat it covers
Vector SearchANN, filtered search, quantization, vector-primary collections
Full-Text SearchBM25, fuzzy, NOT operator, synonyms, hybrid search
Graph QueriesEdge ops, traversal, MATCH patterns, algorithms, GraphRAG
Spatial QueriesOGC predicates, proximity, geofencing, H3, spatial joins
CRDT Operationscrdt_state(), crdt_apply(), conflict policies
Fusion & RRFTwo-source and three-source Reciprocal Rank Fusion, FUSION DSL

SQL Extensions

PageWhat it covers
JSON Operators->, ->> #>, #>>, @>, <@, ?, `?
COPYCOPY FROM (import), COPY TO (export), NDJSON / CSV / JSON array
LISTEN / NOTIFYAsync pgwire notifications, transaction buffering, tenant scoping
Custom TypesCREATE TYPE AS ENUM, CREATE TYPE AS composite, ALTER TYPE ADD VALUE
Window FramesROWS, RANGE, GROUPS frame modes with all boundary combinations
Lateral SubqueriesLATERAL FROM, JOIN LATERAL, planning modes
Recursive CTEsWITH RECURSIVE, value-generating forms, validation rules
Grouping SetsGROUP BY ROLLUP, CUBE, GROUPING SETS, GROUPING() function

Diagnostics

PageWhat it covers
EXPLAINQuery plans, cross-shard dispatch, session variables, introspection

Known Gaps

Features not yet available:

  • Transactional DDLCREATE COLLECTION, CREATE INDEX, and other DDL statements auto-commit and cannot be rolled back inside a multi-statement transaction.
  • EXPLAIN ANALYZE — per-operator runtime stats require Data Plane instrumentation not yet wired. EXPLAIN (plan-only) works.
  • Custom types as pgwire wire-format codecs — enum and composite types are stored and queryable, but the pgwire layer sends them as TEXT rather than their registered OID binary format.
  • ALTER TYPE beyond ADD VALUE — renaming labels, dropping labels, and reordering composite fields are not yet supported.
  • ALTER TYPE … RENAME VALUE — blocked by the same gap above.
  • DROP TYPE cascadeDROP TYPE is protected; it fails if the type is in use. Cascade dropping the dependent collections first is required manually.
  • CHECK constraints, FOREIGN KEY, REFERENCES — rejected at DDL time. See DDL for the canonical replacements.
  • UPDATE/DELETE … JOIN syntax — rewrite as a subquery. UPDATE … FROM is supported; UPDATE … JOIN is not.
  • Full ALTER TABLE / ALTER COLLECTIONADD COLUMN and DROP COLUMN work; renaming columns, changing column types, and adding/dropping constraints are not yet supported.
  • COPY FROM STDIN — the streaming STDIN form is handled only by the backup/restore path. File-path COPY FROM and COPY TO work.
  • LISTEN on non-collection channelsLISTEN subscribes to a collection's change stream. Arbitrary string channel names (Postgres style) are not supported.
  • Prepared statements for DDL — only DML (SELECT, INSERT, UPDATE, DELETE) and some DQL statements support the extended-query (prepared) protocol.
View page sourceLast updated on May 12, 2026 by Farhan Syah