Uploaded image for project: 'Blazegraph (by SYSTAP)'
  1. Blazegraph (by SYSTAP)
  2. BLZG-972

poor optimizer choice: split query into separate components? (simple OR in property path)

    XMLWordPrintable

    Details

      Description

      The optimizer takes this query, which has three totally unrelated parts
      SPARQL

      base <http://localhost:8000/>
      prefix owl: <http://www.w3.org/2002/07/owl#>
      prefix based: </bdm/api/appindividual/based:>
      prefix xsd: <http://www.w3.org/2001/XMLSchema#>
      prefix demod: </bdm/api/appindividual/demod:>
      prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      prefix demo: </bdm/api/kbobject/demo:>
      prefix dc: <http://purl.org/dc/elements/1.1/>
      prefix sys: </bdm/api/kbobject/sys:>
      prefix s: </bdm/api/>
      prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
      prefix bds: <http://www.bigdata.com/rdf/search#>
      prefix sysd: </bdm/api/appindividual/sysd:>
      prefix base: </bdm/api/kbobject/base:>
      prefix skos: <http://www.w3.org/2004/02/skos/core#>
      prefix syapse: </graph/syapse#>
      SELECT *
      #FROM </graph/django/cat-co>
      #FROM </graph/cat-co/abox>
      #FROM </graph/vocabulary>
      #FROM </graph/ontology/sys>
      #FROM </graph/ontology/base>
      #FROM </graph/syapse>
      #FROM </graph/ontology/demo>
      #FROM </graph/cat-co/vocabulary>
      WHERE {
      {}
      ?__concept__1 syapse:inScheme </vocabulary/atcc/cell_line#> ;
        skos:prefLabel | skos:altLabel """CRL-7512""" .
      ?__concept__2 syapse:inScheme </vocabulary/mesh/method_of_administration#> ;
        skos:prefLabel | skos:altLabel """Injections, Subcutaneous""" .
      ?__concept__3 syapse:inScheme </vocabulary/atcc/cell_line#> ;
        skos:prefLabel | skos:altLabel """MF116""" .
      
      }
      

      and converts into this
      Optimized AST

      PREFIX owl: <http://www.w3.org/2002/07/owl#>
      PREFIX based: <http://localhost:8000/bdm/api/appindividual/based:>
      PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
      PREFIX demod: <http://localhost:8000/bdm/api/appindividual/demod:>
      PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      PREFIX demo: <http://localhost:8000/bdm/api/kbobject/demo:>
      PREFIX dc: <http://purl.org/dc/elements/1.1/>
      PREFIX sys: <http://localhost:8000/bdm/api/kbobject/sys:>
      PREFIX s: <http://localhost:8000/bdm/api/>
      PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
      PREFIX bds: <http://www.bigdata.com/rdf/search#>
      PREFIX sysd: <http://localhost:8000/bdm/api/appindividual/sysd:>
      PREFIX base: <http://localhost:8000/bdm/api/kbobject/base:>
      PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
      PREFIX syapse: <http://localhost:8000/graph/syapse#>
      QueryType: SELECT
      includeInferred=true
      SELECT VarNode(__concept__1) VarNode(__concept__2) VarNode(__concept__3)
        JoinGroupNode {
          PropertyPathUnionNode [joinVars=[]] [projectInVars=[]] {
            JoinGroupNode [joinVars=[]] [projectInVars=[]] {
              StatementPatternNode(VarNode(__concept__1), ConstantNode(Vocab(-90)[http://www.w3.org/2004/02/skos/core#prefLabel]), ConstantNode(TermId(24931L)[CRL-7512])) [scope=DEFAULT_CONTEXTS]
                com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=0
                com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
            } JOIN ON ()
            JoinGroupNode [joinVars=[]] [projectInVars=[]] {
              StatementPatternNode(VarNode(__concept__1), ConstantNode(Vocab(-112)[http://www.w3.org/2004/02/skos/core#altLabel]), ConstantNode(TermId(24931L)[CRL-7512])) [scope=DEFAULT_CONTEXTS]
                com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=28
                com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
            } JOIN ON ()
          } JOIN ON ()
          PropertyPathUnionNode [joinVars=[]] [projectInVars=[]] {
            JoinGroupNode [joinVars=[]] [projectInVars=[]] {
              StatementPatternNode(VarNode(__concept__2), ConstantNode(Vocab(-90)[http://www.w3.org/2004/02/skos/core#prefLabel]), ConstantNode(TermId(27789L)[Injections, Subcutaneous])) [scope=DEFAULT_CONTEXTS]
                com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=28
                com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
            } JOIN ON ()
            JoinGroupNode [joinVars=[]] [projectInVars=[]] {
              StatementPatternNode(VarNode(__concept__2), ConstantNode(Vocab(-112)[http://www.w3.org/2004/02/skos/core#altLabel]), ConstantNode(TermId(27789L)[Injections, Subcutaneous])) [scope=DEFAULT_CONTEXTS]
                com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=0
                com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
            } JOIN ON ()
          } JOIN ON ()
          PropertyPathUnionNode [joinVars=[]] [projectInVars=[]] {
            JoinGroupNode [joinVars=[]] [projectInVars=[]] {
              StatementPatternNode(VarNode(__concept__3), ConstantNode(Vocab(-90)[http://www.w3.org/2004/02/skos/core#prefLabel]), ConstantNode(TermId(29063L)[MF116])) [scope=DEFAULT_CONTEXTS]
                com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=28
                com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
            } JOIN ON ()
            JoinGroupNode [joinVars=[]] [projectInVars=[]] {
              StatementPatternNode(VarNode(__concept__3), ConstantNode(Vocab(-112)[http://www.w3.org/2004/02/skos/core#altLabel]), ConstantNode(TermId(29063L)[MF116])) [scope=DEFAULT_CONTEXTS]
                com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=0
                com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
            } JOIN ON ()
          } JOIN ON ()
          StatementPatternNode(VarNode(__concept__2), ConstantNode(TermId(6176U)[http://localhost:8000/graph/syapse#inScheme]), ConstantNode(TermId(1655U)[http://localhost:8000/vocabulary/mesh/method_of_administration#])) [scope=DEFAULT_CONTEXTS]
            com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=47
            com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
          StatementPatternNode(VarNode(__concept__1), ConstantNode(TermId(6176U)[http://localhost:8000/graph/syapse#inScheme]), ConstantNode(TermId(1650U)[http://localhost:8000/vocabulary/atcc/cell_line#])) [scope=DEFAULT_CONTEXTS]
            com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=415
            com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
          StatementPatternNode(VarNode(__concept__3), ConstantNode(TermId(6176U)[http://localhost:8000/graph/syapse#inScheme]), ConstantNode(TermId(1650U)[http://localhost:8000/vocabulary/atcc/cell_line#])) [scope=DEFAULT_CONTEXTS]
            com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=415
            com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
        }
      
      

      This choice is poor because each inScheme triples should ideally occur just before or just after the prefLabel | altLabel choice (in practice just after is better)

        Attachments

          Activity

            People

            Assignee:
            jeremycarroll jeremycarroll
            Reporter:
            jeremycarroll jeremycarroll
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: