[英]SPARQL - CONSTRUCT Query Performance Problem
i've to query a set of statements before i create a new version of an object with the same identifier.在创建具有相同标识符的对象的新版本之前,我必须查询一组语句。 With the result i analyse the changes and reuse referenced objects, if the haven't changed.
结果,我分析更改并重用引用的对象,如果没有更改的话。 But the following query is aweful and very slow.
但是下面的查询很可怕而且很慢。 if there are ~ 1000 object versions, it runs about 120 seconds.
如果有 ~ 1000 个对象版本,它运行大约 120 秒。 and i've to import lot more !
我必须进口更多!
Is there a way to query the statements in a more performant way?有没有办法以更高效的方式查询语句? I know the "OPTIONAL" is bad, but the properties can be empty.
我知道“可选”不好,但属性可以为空。
Thanks谢谢
PREFIX schema: <https://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX as: <https://www.w3.org/ns/activitystreams#>
CONSTRUCT {
?publication rdf:type ?type ;
schema:about ?about ;
schema:about ?about;
schema:name ?name ;
as:name ?asname ;
as:published ?published ;
as:attributedTo ?attributedTo ;
schema:creativeWorkStatus ?creativeWorkStatus ;
schema:dateCreated ?dateCreated ;
schema:dateModified ?dateModified ;
schema:description ?description ;
schema:identifier ?identifier ;
schema:keywords ?keywords ;
schema:license ?license ;
schema:version ?version .
?about rdf:type ?aboutType ;
schema:name ?aboutName ;
schema:contactPoint ?aboutContactPoint ;
schema:location ?aboutLocation .
?aboutContactPoint rdf:type ?contactPointType ;
schema:email ?contactPointEmail ;
schema:name ?contactPointName ;
schema:telephone?contactPointTelephone .
?aboutLocation rdf:type ?locationType ;
schema:latitude ?locationLatitude ;
schema:longitude ?locationLongitude ;
schema:address ?locationAddress .
# Adress
?locationAddress rdf:type ?addressType ;
schema:addressCountry ?addressCountry ;
schema:addressLocality ?addressLocality ;
schema:streetAddress ?addressStreetAddress ;
schema:postalCode ?addressPostalCode .
}
FROM <http://localhost:8081/camel/fef6dc4b-e1e9-46f5-a34e-8ab5c1600ec4>
WHERE {
?publication rdf:type schema:CreativeWork ;
rdf:type ?type ;
schema:identifier "6472c8bbf6504b56b473a1e6a10fcc8d".
OPTIONAL {?publication schema:name ?name . }
OPTIONAL {?publication as:name ?asname . }
OPTIONAL {?publication as:published ?published . }
OPTIONAL {?publication as:attributedTo ?attributedTo . }
OPTIONAL {?publication schema:creativeWorkStatus ?creativeWorkStatus . }
OPTIONAL {?publication schema:dateCreated ?dateCreated . }
OPTIONAL {?publication schema:dateModified ?dateModified . }
OPTIONAL {?publication schema:description ?description . }
OPTIONAL {?publication schema:identifier ?identifier . }
OPTIONAL {?publication schema:keywords ?keywords . }
OPTIONAL {?publication schema:license ?license . }
OPTIONAL {?publication schema:version ?version . }
OPTIONAL {?publication schema:about ?about . }
# Organization
OPTIONAL {?publication schema:about/rdf:type ?aboutType . }
OPTIONAL {?publication schema:about/schema:name ?aboutName . }
OPTIONAL {?publication schema:about/schema:contactPoint ?aboutContactPoint . }
OPTIONAL {?publication schema:about/schema:location ?aboutLocation . }
# ContactPoint
OPTIONAL {?publication schema:about/schema:contactPoint/rdf:type ?contactPointType . }
OPTIONAL {?publication schema:about/schema:contactPoint/schema:email ?contactPointEmail . }
OPTIONAL {?publication schema:about/schema:contactPoint/schema:name ?contactPointName . }
OPTIONAL {?publication schema:about/schema:contactPoint/schema:telephone?contactPointTelephone . }
# Place
OPTIONAL {?publication schema:about/schema:location/rdf:type ?locationType . }
OPTIONAL {?publication schema:about/schema:location/schema:latitude ?locationLatitude . }
OPTIONAL {?publication schema:about/schema:location/schema:longitude ?locationLongitude . }
OPTIONAL {?publication schema:about/schema:location/schema:address ?locationAddress . }
# Adress
OPTIONAL {?publication schema:about/schema:location/schema:address/rdf:type ?addressType . }
OPTIONAL {?publication schema:about/schema:location/schema:address/schema:addressLocality ?addressLocality . }
OPTIONAL {?publication schema:about/schema:location/schema:address/schema:streetAddress ?addressStreetAddress . }
OPTIONAL {?publication schema:about/schema:location/schema:address/schema:postalCode ?addressPostalCode . }
OPTIONAL {?publication schema:about/schema:location/schema:address/schema:addressCountry ?addressCountry . }
}
Use VALUES to avoid OPTIONAL.使用 VALUES 来避免 OPTIONAL。
VALUES ?p {
schema:name
as:name
as:published
as:attributedTo
schema:creativeWorkStatus
schema:dateCreated
schema:dateModified
schema:description
schema:identifier
schema:keywords
schema:license
schema:version
schema:about
}
?publication ?p ?o .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.