I have a sparql-Query, that asks for certain properties of URIs of a given type. As I am not sure, whether those properties exists, I use the OPTIONAL Keyword:
PREFIX mbo: <http://creativeartefact.org/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT * WHERE {
?uri a mbo:LiveMusicEvent.
OPTIONAL {?uri rdfs:label ?label}.
OPTIONAL {?uri mbo:organisedBy ?organiser}.
OPTIONAL {?uri mbo:takesPlaceAt ?venue}.
OPTIONAL {?uri mbo:begin ?begin}.
OPTIONAL {?uri mbo:end ?end}.
}
When I run this query against my SPARQL-Endpoint (Virtuoso Server), I got the error:
Virtuoso 42000 Error The estimated execution time -721420288 (sec) exceeds the limit of 400 (sec).
When I reduce the OPTIONAL clauses, after the first removed clause the estimated execution time is 4106 seconds, when I remove two clauses, the query is executed (and return the values instantly).
I cannot see, why the estimated execution time is skyrocketing like this with the additional OPTIONAL clauses, but maybe I'm just using a wrong constructed query?
from [construct { ... } where { ... }] select ... where { ... }
. It would make some difficult tasks very easy. – Alcides