Lam NguyenPublications

Publications · Preprint, 2026

OntoDB: A Fast and Persistent Query Engine for Ontologies

L. Nguyen

TL;DR One multi-threaded, disk-based engine for patterns, class hierarchies and similarity: a B+ tree triple store that scales across threads, the class hierarchy kept as intervals of the same tree, and vector indexes inside the engine. Faster than Oxigraph, Jena TDB2 and SQLite on selective queries and class instances, and it runs in a browser.

Read the PDF Extended version Code Manual Playground

Highlights

Abstract

Ontologies are queried in three ways: for the triples that match a pattern, for the instances at or below a class, and for the terms closest in meaning to a given term. Triple stores answer the first well, handle the second by rewriting queries or by materializing entailed triples, and leave the third to a separate vector database; none is built to serve many threads from one embedded engine, or to run in a web page. We present OntoDB, an ontology database that answers all three kinds of query inside one disk-based, multi-threaded engine. Through OntoDB we make the following contributions. (1) A B+ tree triple store of three permutations behind a buffer pool, with algorithms for search, insert, delete, range scan, and bulk load, a bound on the pages a range scan reads, and write-ahead logging with ARIES-style recovery for persistence. (2) A concurrency design that scales: an optimistic leaf-only descent for inserts and deletes, a sharded buffer pool whose hits take no latch, and a one-word page latch. (3) A labelling of the class hierarchy with postorder intervals kept in the same B+ tree, so that ``everything under a class'' is a few range scans and no entailed triple is stored, and a plan rewrite that answers RDFS subclass entailment of exttt{rdf:type} patterns with these scans, with the answers of materialization, prepared 16 times faster and in 8 times less space. (4) Exact, IVF, product-quantized, and HNSW vector indexes in the engine, a proof that no linear order of points keeps neighbors close, and the finding that in an ontology a class filter is correlated with the vectors, so the usual independence assumption fails. (5) A 0.85 MB WebAssembly build that runs the engine in a browser. On LUBM and the Gene Ontology, against Oxigraph, Apache Jena TDB2, and SQLite, OntoDB answers selective triple patterns 3 to 37x faster and the instances of a class 2 to 48x faster, and serves 3 to 7x more lookups per second with eight threads (1.46 million per second). Its interval labels store 8.1x fewer triples than materializing the hierarchy and read 48x fewer pages than rewriting the query, and exact pre-filtering through them is 100 to 10^4 imes faster than any index strategy for classes below about 1,000 members.

Read

On a phone, open the PDF in your browser's reader.

Cite

@misc{nguyen2026ontodb,
  title  = {{OntoDB}: A Fast Ontology Database for Pattern, Hierarchy, and Semantic Queries},
  author = {Lam Nguyen},
  year   = {2026},
  note   = {Preprint},
  url    = {https://github.com/lamng3/OntoDB}
}