You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Giovanni Mels (JIRA)" <ji...@apache.org> on 2013/01/21 12:02:13 UTC

[jira] [Created] (JENA-383) Query

Giovanni Mels created JENA-383:
----------------------------------

             Summary: Query 
                 Key: JENA-383
                 URL: https://issues.apache.org/jira/browse/JENA-383
             Project: Apache Jena
          Issue Type: Improvement
          Components: ARQ
    Affects Versions: ARQ 2.9.4
            Reporter: Giovanni Mels
            Priority: Minor


The query optimizer generates a suboptimal query plan in case of nested optionals followed by a filter (?var = <uri>).

The problem is similar to the problem discussed here http://markmail.org/message/zy5qx47hxfo2vdlg, except we have nested optionals in our query (There are no scope problems, all optionals are translated to conditionals). It is only the filter that is translated differently:

arq-2.8.8

  (extend ((?var <uri>))
    (conditional
      (conditional
        (conditional
          (conditional
            (conditional
              (conditional
                (bgp
				...
				
jena-arq-2.9.4

  (filter (= ?var <uri>)
    (conditional
      (conditional
        (conditional
          (conditional
            (conditional
              (conditional
                (bgp
				...

Query times went from milliseconds to over 7 minutes because of this.

I reduced the query to this test case:

PREFIX ex: <http://example.org/test#>

SELECT * WHERE {

    ?var ex:p1 ?x.
    
    OPTIONAL {
        ?x ex:p2 ?y.
        
        OPTIONAL {
            ?y ex:p3 ?z
        }
    }
    
    FILTER (?var = ex:i)
}

  (filter (= ?var <http://example.org/test#i>)
    (conditional
      (bgp (triple ?var <http://example.org/test#p1> ?x))
      (conditional
        (bgp (triple ?x <http://example.org/test#p2> ?y))
        (bgp (triple ?y <http://example.org/test#p3> ?z)))))
		
		
The nested OPTIONAL seems to be the problem here, removing it gives

  (assign ((?var <http://example.org/test#i>))
    (conditional
      (bgp (triple <http://example.org/test#i> <http://example.org/test#p1> ?x))
      (bgp
        (triple ?x <http://example.org/test#p2> ?y)
        (triple ?y <http://example.org/test#p3> ?z)
      )))
 

This might be related to JENA-294. 


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira