SPARQL otimizations
3274437 Aug 11, 2016 4:40 PMDear all,
We need to execute a query that looks like the bellow. In this case, the result has only 9 rows.
For the subqueries, we notice that using ALL_LINK_HASH for the object properties (e.g. lines 8 to 11) and putting other properties/filters/binds in a different BGP (e.g. lines 12 to 16) improves the performance over 10x.
However, we are wondering if there are other recommendations for this type of query. We are using semantic indexes PCSGM, PSCGM, PSCM, CPSM and SCPM, and executing the function SEM_APIS.ANALYZE_MODEL.
PREFIX : <http://example.org/> SELECT ?I_C0 ?C0 ?I_C2 ?C1 ?P0 ?P1 WHERE { ?I_C0 rdfs:label ?C0 . ?I_C2 rdfs:label ?C1 { { { SELECT ?I_C0 ?I_C2 ?P0 ?P1 WHERE { { # HINT0={ALL_LINK_HASH} ?I_C1 :C1#C3_CD_C3 ?I_C0 . ?I_C2 :C2#ID_C1 ?I_C1 } { ?I_C2 :C2#P4 ?P0 . ?I_C0 :C3#P5 ?P2 . FILTER orardf:textContains(?P2, "fuzzy({ exploração }, 70, 1)", 1) BIND(concat("Unidade P5: ", str(?P2), "") AS ?P1) } } LIMIT 750 } UNION { SELECT ?I_C0 ?I_C2 ?P0 ?P1 WHERE { { # HINT0={ALL_LINK_HASH} ?I_C1 :C1#C3_CD_C3 ?I_C0 . ?I_C2 :C2#ID_C1 ?I_C1 } { ?I_C2 :C2#P4 ?P0 . ?I_C0 :C3#P6 ?P3 . FILTER orardf:textContains(?P3, "fuzzy({ exploração }, 70, 1)", 1) BIND(concat("Unidade P6: ", str(?P3), "") AS ?P1) } } LIMIT 750 } UNION { SELECT ?I_C0 ?I_C2 ?P0 ?P1 WHERE { { # HINT0={ALL_LINK_HASH} ?I_C1 :C1#C3_CD_C3 ?I_C0 . ?I_C2 :C2#ID_C1 ?I_C1 } { ?I_C2 :C2#P4 ?P0 . ?I_C0 :C3#P7 ?P4 . FILTER orardf:textContains(?P4, "fuzzy({ exploração }, 70, 1)", 1) BIND(concat("Unidade P7: ", str(?P4), "") AS ?P1) } } LIMIT 750 } UNION { SELECT ?I_C0 ?I_C2 ?P0 ?P1 WHERE { { # HINT0={ALL_LINK_HASH} ?I_C1 :C1#C3_CD_C3 ?I_C0 . ?I_C2 :C2#ID_C1 ?I_C1 } { ?I_C2 :C2#P4 ?P0 . ?I_C0 :C3#P8 ?P5 . FILTER orardf:textContains(?P5, "fuzzy({ exploração }, 70, 1)", 1) BIND(concat("Unidade P8: ", str(?P5), "") AS ?P1) } } LIMIT 750 } } } } LIMIT 750
Thanks in advance.