Level / level-js

An abstract-leveldown compliant store on top of IndexedDB.
MIT License
544 stars 44 forks source link

Slow speed on simple SPARQL query #216

Closed KonradHoeffner closed 3 years ago

KonradHoeffner commented 3 years ago

The query SELECT ?c ?l WHERE { ?c a owl:Class; rdfs:label ?l. } takes 111s on an Intel Core i9 10900k to retrieve 1246 hits from a turtle file of size 1.2 MB when used with level-js (using the browser bundle) as a backend for Quadstore, which is too slow for my use case. Is that level of performance expected or is there a way to improve it?

<script src="https://cdn.jsdelivr.net/gh/beautifulinteractions/node-quadstore-webpack-bundle/quadstore.bundle.js"></script>
[...]
const { leveljs, Quadstore, DataFactory, newEngine } = quadstore;
const dataFactory = new DataFactory();
const store = new Quadstore({
    dataFactory,
    backend: leveljs("bb"),
    comunica: newEngine(),
});

const URL = "http://0.0.0.0:8000/bb.ttl";
const response = await fetch(URL);

const text = await response.text();
const parser = new Parser({ format: "rdf/turtle" });
await store.open();
const quads = parser.parse(text);
store.multiPut(quads);
const { type, items } = await store.sparql(query);
vweevers commented 3 years ago

I would ask the authors of QuadStore. If you can find specific level-js operations to optimize, that would be welcome of course.

KonradHoeffner commented 3 years ago

Unfortunately I don't know the internals of level-js to know which operations are behind the query, but the author of QuadStore told me that the reason of the performance is level-js. I just wanted to know if this is about as expected or if I should investigate whether there is something wrong with the way I set it up. I will continue investigating in the QuadStore direction then.