我有一个简单的SPARQL查询,它使用本地Fuseki SPARQL端点在我的Jena TDB商店上执行得相当快:
SELECT DISTINCT ?p
WHERE
{
?s rdf:type dbpedia-owl:Organisation .
?s ?p dbpedia:California .
}
LIMIT 10
完成它可能需要10秒钟,并且包含一些owl:ObjectProperty和其他属性。当我想使用以下查询仅显示对象属性时(请注意结尾处的额外三元组和限制1):
SELECT DISTINCT ?p
WHERE
{
?s rdf:type dbpedia-owl:Organisation .
?s ?p dbpedia:California .
?p a owl:ObjectProperty .
}
LIMIT 1
然后我希望答案看起来同样快,并且只显示之前显示的一个对象属性。毕竟,它只是对前一个查询的进一步细化。但是,查询需要花费很多倍,并在几分钟后完成,而不是几秒钟。
我很困惑。为什么第二个查询需要更长时间?
我使用的是Fuseki 1.1.0版。这是我的fuseki配置文件:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix text: <http://jena.apache.org/text#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix : <http://localhost/dbpedia37#> .
[] rdf:type fuseki:Server ;
fuseki:services (
:service_text_tdb
) .
## Example of a TDB dataset and text index
## Initialize TDB
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
## Initialize text query
[] ja:loadClass "org.apache.jena.query.text.TextQuery" .
# A TextDataset is a regular dataset with a text index.
text:TextDataset rdfs:subClassOf ja:RDFDataset .
# Lucene index
text:TextIndexLucene rdfs:subClassOf text:TextIndex .
## ---------------------------------------------------------------
## This URI must be fixed - it's used to assemble the text dataset.
:text_dataset rdf:type text:TextDataset ;
text:dataset :dataset ;
text:index :indexLucene ;
.
# A TDB datset used for RDF storage
:dataset rdf:type tdb:DatasetTDB ;
tdb:location "/Users/jsimon/No-Backup/dbpedia37/tdb" ;
# tdb:unionDefaultGraph true ; # Optional
.
# Text index description
:indexLucene a text:TextIndexLucene ;
text:directory <file:Lucene> ;
##text:directory "mem" ;
text:entityMap :entMap ;
.
# Mapping in the index
# URI stored in field "uri"
# rdfs:label is mapped to field "text"
:entMap a text:EntityMap ;
text:entityField "uri" ;
text:defaultField "text" ;
text:map (
[ text:field "text" ; text:predicate rdfs:label ]
[ text:field "text" ; text:predicate foaf:name ]
) .
:service_text_tdb rdf:type fuseki:Service ;
rdfs:label "TDB/text service" ;
fuseki:name "ds" ;
fuseki:serviceQuery "query" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceUpload "upload" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:dataset :text_dataset ;
.