Skip to content
Peter Styk HPC & AI Platform Engineer

Project · A database

pgRDF: knowledge graphs inside PostgreSQL

pgRDF puts RDF, SPARQL, SHACL and OWL reasoning inside stock PostgreSQL, as an extension. It is the base the rest of the study builds meaning on: one graph that holds code and prose, judges them by shapes, and keeps every verdict as data.

pgRDF documentationSource on GitHubHear it explained

pgRDF keeps one store inside PostgreSQL and does four things with it. Store: triples are rows in ordinary PostgreSQL tables, one partition a graph; 8.2 billion triples were loaded in 4 hours 53 minutes on 128 vCPU, measured on version 0.6.14. Judge: SHACL shapes give a verdict inside the database and each verdict is kept on record; 98 of 98 W3C SHACL Core tests pass. Reason: OWL 2 RL and RDFS rules add the facts that follow, stored and queried like stated ones. Ask: SPARQL 1.1, beside everything else the database holds; results join with any table. The store holds a repository's code, read into RDF by OntoSys, prose beside it, and the shapes that judge them, a graph of their own.
One store, inside PostgreSQLDownload SVG
Bulk load · v0.6.14, June 20268.2 bntriples into PostgreSQL in 4 h 53 min on one Azure E128ads_v7 (AMD EPYC), on local NVMe striped in RAID0.
Validation · v0.6.4498 of 98W3C SHACL Core tests pass, graded on the sh:conforms verdict and gated in CI in all three validation modes.
Writes, at peak8.65 GB/son the striped NVMe; the same load on network disk took 5.3 times longer to index.

What it is

A graph database that lives in PostgreSQL

Store and query

RDF stored in PostgreSQL tables and queried with SPARQL 1.1, beside everything else the database already holds.

Judge

SHACL validation inside the database. The report comes back as data, so what failed, where and why can be counted and queried, and each verdict is kept on record. W3C SHACL Core: 98 of 98 tests, in all three validation modes, on the sh:conforms verdict. SHACL-SPARQL: 10 of 23 W3C tests gated so far.

Reason

OWL 2 RL and RDFS reasoning, materialised in the database, so derived facts are queried like stated ones.

Release on evidence

CI-only releases with SLSA build provenance; each result admitted by its hash, and the published version advances only after verification.

Hear it · Why it matters · 0:32

Why frame it as pillars? Because RDF tooling historically arrives in pieces. You bolt together a triple store, a SPARQL endpoint, a reasoner, and a SHACL engine, each from a different vendor, each with its own deployment, each disagreeing about what's actually in the graph. pgRDF puts all four in the same database, against the same tables, under the same transaction. That's the bet — that the operational simplicity of one Postgres is worth doing the engineering inside the extension.

From “The four pillars at a glance”. Keep listening

How the load was decided

Storage chosen by measurement

The record load ran on local NVMe that cloud-init stripes into RAID0 at first boot, with PostgreSQL set for bulk load. The choice came from measuring: on network disk the same load took 5.3 times longer to index.

The store hop, in the study

Hear it · Why it matters · 0:33

Why bother? Because RDF data, when you store it naively, is brutally repetitive. The same predicate IRI — say, foaf-name or rdf-type — might appear in millions of triples. If you stored each of those as a text column, you'd be paying for the same string over and over again. And on the query side, a SPARQL triple pattern can leave any subset of subject, predicate, and object unbound — so the storage layer needs to answer questions efficiently regardless of which corners are pinned and which are open.

From “Hexastore and dictionary encoding”. Keep listening

Works with

A repository’s code, held as a graph

OntoSys reads a repository’s code into RDF; pgRDF holds it, judges it by shapes and answers questions across it.

OntoSys

Listen

pgRDF, explained out loud

Fifty-two short explanations, from how a triple is stored to how a shape judges it, read by a face. They are laid out as a map: start anywhere and follow where each one points.

Hear it · Why it matters · 0:21

The interesting bit isn't that you can validate — every triple store can. It's that the validation, the data, and the rollback are all in the same Postgres transaction. No second system. No eventual consistency between a validation log and the actual database. If a load fails validation, it disappears, atomically.

From “The mental model — SHACL validation”. Keep listening

Open the map

Other projects

Where else the study goes

All research