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

mis-optimation of quad pattern vs triple pattern

    XMLWordPrintable

    Details

      Description

      The following query is optimized as shown below, note that with the commented out lines enabled the performance is acceptable: this shows that the reordering of the optimizer was incorrect.

      base <http://localhost:8000/>
      prefix owl: <http://www.w3.org/2002/07/owl#>
      prefix xsd: <http://www.w3.org/2001/XMLSchema#>
      prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      prefix dc: <http://purl.org/dc/elements/1.1/>
      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 skos: <http://www.w3.org/2004/02/skos/core#>
      prefix syapse: <http://localhost:8000/graph/syapse#>
      SELECT DISTINCT ?vocab_id ?title ?creator ?count
      FROM <http://localhost:8000/graph/syapse>
      FROM <http://localhost:8000/graph/customer/vocabulary>
      FROM <http://localhost:8000/graph/vocabulary>
      FROM NAMED <http://localhost:8000/graph/syapse>
      FROM NAMED <http://localhost:8000/graph/customer/vocabulary>
      FROM NAMED <http://localhost:8000/graph/vocabulary>
      
      WHERE {
      
              ?vocab dc:title ?title .
              ?vocab syapse:shortId ?vocab_id .
              { SELECT ?vocab (COUNT(*) AS ?count )
                { GRAPH <http://localhost:8000/graph/customer/vocabulary> {
                     ?c skos:prefLabel | skos:altLabel ?t
                  }
             #     { SELECT ?c ?vocab {
                  ?c syapse:inScheme ?vocab
             #     } }
                } GROUP BY ?vocab
              }
              OPTIONAL {
                ?vocab dc:creator ?creator
              }
              
      }
      ORDER BY ?title}}}
      
      
      optimized to
      
      {{{
      PREFIX owl: <http://www.w3.org/2002/07/owl#>
      PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
      PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      PREFIX dc: <http://purl.org/dc/elements/1.1/>
      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 skos: <http://www.w3.org/2004/02/skos/core#>
      PREFIX syapse: <http://localhost:8000/graph/syapse#>
        defaultGraphs=DataSetSummary{ngraphs=3, nknown=3, nunknown=0, graphs=[TermId(1U)[http://localhost:8000/graph/syapse], TermId(9U)[http://localhost:8000/graph/vocabulary], TermId(6176265U)[http://localhost:8000/graph/customer/vocabulary]]}
        namedGraphs=DataSetSummary{ngraphs=3, nknown=3, nunknown=0, graphs=[TermId(1U)[http://localhost:8000/graph/syapse], TermId(9U)[http://localhost:8000/graph/vocabulary], TermId(6176265U)[http://localhost:8000/graph/customer/vocabulary]]}
      WITH {
        QueryType: SELECT
        SELECT ( VarNode(vocab) AS VarNode(vocab) ) ( com.bigdata.rdf.sparql.ast.FunctionNode(VarNode(*))[ com.bigdata.rdf.sparql.ast.FunctionNode.scalarVals=null, com.bigdata.rdf.sparql.ast.FunctionNode.functionURI=http://www.w3.org/2006/sparql-functions#count, valueExpr=com.bigdata.bop.rdf.aggregate.COUNT(*)] AS VarNode(count) )
          JoinGroupNode {
            StatementPatternNode(VarNode(c), ConstantNode(TermId(5U)[http://localhost:8000/graph/syapse#inScheme]), VarNode(vocab)) [scope=DEFAULT_CONTEXTS]
              com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=963805
              com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
            PropertyPathUnionNode [joinVars=[c]] [projectInVars=[c]] {
              JoinGroupNode [joinVars=[c]] [projectInVars=[c]] {
                StatementPatternNode(VarNode(c), ConstantNode(Vocab(-90)[http://www.w3.org/2004/02/skos/core#prefLabel]), VarNode(t), ConstantNode(TermId(6176265U)[http://localhost:8000/graph/customer/vocabulary])) [scope=NAMED_CONTEXTS]
                  com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=607
                  com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=PCSO
              } JOIN ON (c)
              JoinGroupNode [joinVars=[c]] [projectInVars=[c]] {
                StatementPatternNode(VarNode(c), ConstantNode(Vocab(-112)[http://www.w3.org/2004/02/skos/core#altLabel]), VarNode(t), ConstantNode(TermId(6176265U)[http://localhost:8000/graph/customer/vocabulary])) [scope=NAMED_CONTEXTS]
                  com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=478
                  com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=PCSO
              } JOIN ON (c)
            } JOIN ON (c)
          }
        group by ( VarNode(vocab) AS VarNode(vocab) )
      } AS -subSelect-1 JOIN ON (VarNode(vocab)) DEPENDS ON ()
      QueryType: SELECT
      includeInferred=true
      SELECT DISTINCT ( VarNode(vocab_id) AS VarNode(vocab_id) ) ( VarNode(title) AS VarNode(title) ) ( VarNode(creator) AS VarNode(creator) ) ( VarNode(count) AS VarNode(count) )
        JoinGroupNode {
          StatementPatternNode(VarNode(vocab), ConstantNode(Vocab(-73)[http://purl.org/dc/elements/1.1/title]), VarNode(title)) [scope=DEFAULT_CONTEXTS]
            com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=74
            com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
          StatementPatternNode(VarNode(vocab), ConstantNode(TermId(7U)[http://localhost:8000/graph/syapse#shortId]), VarNode(vocab_id)) [scope=DEFAULT_CONTEXTS]
            com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=86
            com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
          INCLUDE -subSelect-1 JOIN ON (VarNode(vocab))
          StatementPatternNode(VarNode(vocab), ConstantNode(Vocab(-72)[http://purl.org/dc/elements/1.1/creator]), VarNode(creator)) [scope=DEFAULT_CONTEXTS] [optional]
            com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=89
            com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
        }
      ORDER BY com.bigdata.rdf.sparql.ast.OrderByExpr(VarNode(title))[ ascending=true]
      

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: