I want to execute the following SPARQL against my local Apache Jena (with preloaded Wikidata dump using TDB2):
When run on query.wikidata.org (which uses Blazegraph), this query takes 26 seconds to complete. Other queries run in about the same time as on query.wikidata.org.
Apache Jena runs for several hours, using one CPU core and 3-4 GB of memory. Then it runs into some timeout (the timeout might be increased, but that's not the issue here).
My question is, why is this so much slower than Blazegraph? Can this SPARQL be optimized to get a better performance? Can the query optimizer be tweaked to run this more efficiently?
If not, then I consider this a bug, because the query itself should not generate such a big workload. If the query optimizer runs the
predicate first, then limits it via the
clause, there would be just one item for which it needs to execute the