You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2013/12/24 17:31:52 UTC

[jira] [Comment Edited] (JENA-383) The query optimizer generates a suboptimal query plan in case of nested optionals followed by a filter

    [ https://issues.apache.org/jira/browse/JENA-383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13856382#comment-13856382 ] 

Andy Seaborne edited comment on JENA-383 at 12/24/13 4:31 PM:
--------------------------------------------------------------

JENA-595 includes part of this optimization (where safe).


was (Author: andy.seaborne):
JENA-595 includes this optimization (where safe).

> The query optimizer generates a suboptimal query plan in case of nested optionals followed by a filter
> ------------------------------------------------------------------------------------------------------
>
>                 Key: JENA-383
>                 URL: https://issues.apache.org/jira/browse/JENA-383
>             Project: Apache Jena
>          Issue Type: Improvement
>          Components: ARQ, Optimizer
>    Affects Versions: ARQ 2.9.4
>            Reporter: Giovanni Mels
>            Assignee: Andy Seaborne
>              Labels: filter, nested, optimization, optional
>             Fix For: Jena 2.11.1
>
>         Attachments: simple-query.rq
>
>
> 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 was sent by Atlassian JIRA
(v6.1.5#6160)