我在Sesame和Jena上运行以下查询。
SELECT ?x ?y
{ ?x p1+ ?y .
?x p2/p3 ?z .
?y p2/p3 ?z .
FILTER(?x=<http://article.com/1-3> && ?y=<http://article.com/1-1> && not exists {
?k p1 ?x }
)}
要在Jena上评估这些查询,50到200MB之间的文件总是需要10秒以上。
而在芝麻中,它永远不会超过0.3秒。可以查询重写是什么原因吗?
当我按如下方式重写查询时,在Jena中评估查询也需要大约0.5秒:
select ?x ?y {
values(?x ?y){(<http://article.com/1-3> <http://article.com/1-1>)}
?z ^(p2/p3) ?x, ?y .
?x p1+ ?y .
}
在芝麻中,我使用以下一行:
TupleQuery tupleQuery =
con.prepareTupleQuery(QueryLanguage.SPARQL, selectQuery);
而在耶拿,以下内容:
DatasetGraph dsg = DatasetGraphFactory.create(g);
Query query = QueryFactory.create(queryString);
Dataset ds = DatasetFactory.create(dsg);
QueryExecution qexec = QueryExecutionFactory.create(query, ds);