What Is pg_ripple?

pg_ripple turns your PostgreSQL database into a knowledge graph store — and into the foundation for AI applications that need verifiable, structured, traceable answers rather than hallucinated ones.

You can build a chatbot that answers questions from your own knowledge base, deduplicate customer records across systems, validate data quality with formal rules, run OWL reasoning, and answer SPARQL queries over billions of triples — all inside the PostgreSQL you already operate, with no extra infrastructure.

-- Ask a natural-language question against your knowledge graph.
SELECT pg_ripple.rag_context('Which drugs interact with metformin?', k := 8);
-- Returns structured context ready to pass to an LLM.

-- Or query directly in SPARQL.
SELECT * FROM pg_ripple.sparql($$
  PREFIX ex: <https://example.org/>
  SELECT ?name WHERE {
    ex:alice <http://xmlns.com/foaf/0.1/knows>+ ?person .
    ?person  <http://xmlns.com/foaf/0.1/name>   ?name .
  }
$$);
-- Follows the foaf:knows relationship through any number of hops.

The three problems pg_ripple solves

1. AI that knows what it knows — and can prove it

LLM responses fabricate facts because the model has no reliable source of truth. rag_context() retrieves structured graph context for any question in a single SQL call, grounding the LLM's answer in your data. Every retrieved fact links back to its source triple, PROV-O provenance, and audit log entry.

AI Overview & Decision Tree | Chatbot Recipe

2. Record linkage and deduplication at database speed

Deduplicate customer records across CRM and ERP, align external ontologies, or merge research entity mentions — all inside one PostgreSQL transaction. Knowledge-graph embeddings generate candidates; SHACL hard rules block unsafe merges; owl:sameAs canonicalization makes the merged view transparent to every downstream query.

Record Linkage | Dedup Recipe

3. Knowledge graph + relational + vector in one transaction

No separate graph store, no separate vector index, no separate schema registry. One pg_dump captures everything. One ACID transaction spans triple writes, vector index updates, and ordinary table updates together.

Architecture at a Glance | Comparison vs Alternatives


Key capabilities

CapabilityWhat it does
SPARQL 1.1W3C standard graph query — full conformance, < 10 ms typical
SHACL validationDefine and enforce data-quality rules — reject bad data on insert
Datalog reasoningDerive new facts from RDFS, OWL RL/EL/QL, or custom rules
Vector + graph hybridSPARQL traversal combined with pgvector HNSW similarity search
RAG pipelinerag_context() — one call retrieves structured LLM context
NL → SPARQLsparql_from_nl() — auto-generate SPARQL from natural-language questions
Record linkageKGE embeddings + SHACL gates + owl:sameAs canonicalization
GraphRAGMicrosoft GraphRAG ingest, enrich, validate, export pipeline
FederationQuery Wikidata, DBpedia, and other SPARQL endpoints alongside local data
R2RMLGenerate an RDF graph from any existing PostgreSQL schema
JSON-LD framingExport nested JSON documents shaped to your API contract
SPARQL ProtocolStandard HTTP endpoint via pg_ripple_http

Key numbers

MetricValue
Bulk load throughput> 100 K triples/sec (commodity hardware)
SPARQL query latency< 10 ms for typical star patterns
W3C SPARQL 1.1100 % conformance
W3C SHACL Core100 % conformance
W3C OWL 2 RL100 % conformance
PostgreSQL version18

Architecture at a glance

┌─────────────────────────────────────────────────┐
│                  PostgreSQL 18                   │
│  ┌───────────────────────────────────────────┐  │
│  │              pg_ripple extension           │  │
│  │  ┌─────────┐  ┌────────┐  ┌───────────┐  │  │
│  │  │Dictionary│  │ SPARQL │  │  Datalog   │  │  │
│  │  │ Encoder  │  │ Engine │  │  Engine    │  │  │
│  │  └────┬─────┘  └───┬────┘  └─────┬─────┘  │  │
│  │       │             │             │         │  │
│  │  ┌────┴─────────────┴─────────────┴─────┐  │  │
│  │  │     VP Tables (one per predicate)     │  │  │
│  │  │   HTAP: delta + main + merge worker   │  │  │
│  │  └──────────────────────────────────────┘  │  │
│  └───────────────────────────────────────────┘  │
└─────────────────────────────────────────────────┘
         ▲                          ▲
         │ SQL                      │ HTTP
    Application              pg_ripple_http

Every IRI, literal, and blank node is mapped to a compact integer ID by the dictionary encoder. Data is stored in Vertical Partitioning (VP) tables — one table per unique predicate — with integer-only joins for fast query execution. The HTAP architecture separates read and write paths so that heavy loads do not block queries.


Start here — pick your path

Your roleStart withThen exploreGo deeper
PostgreSQL DBA — you know PostgreSQL, new to RDFInstallationHello WorldKey Concepts (RDF for PG users)Operations, Tuning
Data / AI Engineer — building RAG or knowledge pipelinesAI OverviewGrounded ChatbotVector + Hybrid SearchGraphRAG, NL-to-SPARQL
Semantic Web / RDF Engineer — you know SPARQL and OWLSPARQL FeaturesDatalogSHACL ValidationFederation, OWL Profiles

Next steps