Skip to content

Introduction

At a glance

pgRDF · Semantic web inside PostgreSQL · Status Alpha · License Apache-2.0 · Postgres 14 · 15 · 16 · 17 · Latest release v0.4.0 · crates.io · GitHub · Install →

pgRDF is a PostgreSQL extension that turns your Postgres database into a high-performance semantic-web platform. Written in Rust on top of pgrx, it provides four real engines under one extension surface:

EngineWhat it doesEntry-point UDFs
StorageDictionary-encoded triples in LIST-partitioned tables with SPO / POS / OSP covering indexes.pgrdf.load_turtle, pgrdf.parse_turtle, pgrdf.add_graph
SPARQLSPARQL 1.1 SELECT/ASK — parsed via spargebra, translated to dynamic SQL, executed with a per-backend plan cache.pgrdf.sparql, pgrdf.sparql_parse
InferenceOWL 2 RL forward-chaining via the reasonable reasoner. Writes inferences back as queryable rows.pgrdf.materialize
ValidationSHACL Core via the rudof project's shacl crate. Returns a W3C sh:ValidationReport-shape JSONB document.pgrdf.validate

All four engines run inside Postgres. There's no separate service, no second deployment surface, no extra protocol. Every operation is addressable from any Postgres client (psql, psycopg, sqlx, pgx, postgres.js — anything that speaks the Postgres wire protocol).

sql
-- One-time install
CREATE EXTENSION pgrdf;

-- Load any Turtle file from the server filesystem
SELECT pgrdf.load_turtle('/fixtures/ontologies/foaf.ttl', 100);
--  → 631

-- Query with SPARQL
SELECT * FROM pgrdf.sparql(
  'PREFIX foaf: <http://xmlns.com/foaf/0.1/>
   SELECT ?s ?n WHERE { ?s foaf:name ?n }');

-- Materialize OWL 2 RL inferences
SELECT pgrdf.materialize(100);
--  → {"base_triples": 631, "inferred_triples_written": 1842, ...}

-- Validate against SHACL shapes
SELECT pgrdf.validate(100, 200);
--  → {"conforms": true, "results": []}

This documentation tracks the v0.5 target — a coherent capability set combining the shipped v0.4 surface with the in-flight forward edges. Items not yet callable on main are marked 🚀 Forward edge with a link to the relevant LLD section.

Why pgRDF, not a separate triplestore?

Knowledge graphs are usually deployed as a second database alongside Postgres — with their own backups, IAM, observability, SLOs, and operator burden. Application code glues two systems together over the wire.

pgRDF takes a different view:

ConcernSeparate triplestorepgRDF
Where the graph livesSecond process treeInside Postgres
Connection poolNewReuses your existing pool
Backup / WAL / PITRBespokeInherited from Postgres
IAM, auth, TLSBespokeInherited from Postgres
Multi-tenancyBespokeLIST partitions per graph_id
Composition with SQLBridge layerNative — SPARQL is a set-returning SQL function
MonitoringExtra agentStandard Postgres tooling + pgrdf.stats()
Install footprintCluster, operator, CRDThree files bind-mounted onto a stock PG image

You also get the four standard semantic-web operations — load Turtle, SPARQL query, OWL 2 RL materialize, SHACL validate — first-class.

Audience

This site is the user-facing documentation. It assumes you know SQL and at least the basics of RDF, SPARQL, OWL, and SHACL — but not all four. Each pillar's documentation can be read independently.

Where this content comes from

This site translates the canonical feature spec SPEC.pgRDF.v0.5.FEATURES.md into a per-feature documentation surface. Each page here cites the test fixture in styk-tv/pgRDF/tests/ that pins the contract — every feature is real and tested, not aspirational. Where surface is still in flight (not yet callable on main), it's clearly marked 🚀 Forward edge with a link to the relevant LLD section: SPEC.pgRDF.LLD.v0.4.md for in-flight items and SPEC.pgRDF.LLD.v0.5-FUTURE.md for the next-cut target.

Get the bits

See Drop-in install for the five-minute path on stock postgres:17.4 containers via per-file bind mounts. The full install spec is SPEC.pgRDF.INSTALL.v0.2.md.

Next — the four pillars →

Apache-2.0 licensed. Documentation for pgRDF — built with VitePress, served via GitHub Pages.