Skip to content

SPARQL construct - not finishing on larger data #987

Discussion options

You must be logged in to vote

The query is quite generic like this, causing lots of joins and poor performance. It would be better to fit the predicates and classes present in the data.
Also, careful of the OPTIONALS as like this, you are doing a cartesian product as ?o ?p2 ?o2 is independent of ?o2 ?p5 ?o3.

This one without the parents works quite well:

PREFIX sp: <http://spinrdf.org/sp#>
PREFIX msmt: <http://msmt.cz/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

CONSTRUCT {
   ?sub ?p ?o .
   ?o ?p2 ?o2 .
   ?o2 ?p5 ?o3 .
}
WHERE {
     ?sub ?p ?o .
     ?sub msmt:kraj ?kraj .
     FILTER(?kraj = 'Pardubický kraj') .
     OPTIONAL {?o ?p2 ?o2 OPTIONAL {?o2 ?p5 ?o3} } .
     
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by martina-parkanova
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants