Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-885

Poor performance and timeout failure with BIND in nested OPTIONALs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Jena 2.11.2
    • Jena 3.0.1
    • None
    • None

    Description

      There appears to be a performance issue with BIND when used inside nested OPTIONALs. Affected queries fail to time out.

      The following patterns appear to be affected:

      OPTIONAL { ... OPTIONAL { ... BIND ( ... ) } }
      OPTIONAL { ... OPTIONAL { ... } BIND ( ... ) }
      

      The following patterns appear to be unaffected:

      OPTIONAL { ... OPTIONAL { ... } } BIND ( ... )
      OPTIONAL { ...  BIND ( ... ) }
      OPTIONAL { ... } BIND ( ... )
      

      So far, users have been able to work around the performance issue by rewriting their queries. However, the timeout failure is still a significant reliability issue, since affected queries consume resources and can run indefinitely. I've attached a testcase that exhibits the performance and timeout problems. Reproduced with a recent 2.13.0-SNAPSHOT build.

      Execution Timeout (ms): 30000
      
      Query: PREFIX ex: <http://example.com/> SELECT ?s ?valueA { OPTIONAL { ?s ex:propA ?a . OPTIONAL { ?a ex:label ?labelA . } } BIND ( IF ( BOUND (?labelA), ?labelA, ?a) as ?valueA) }
      Execution time (ms): 586
      Execution time (ms): 143
      
      Query: PREFIX ex: <http://example.com/> SELECT ?s ?valueA { OPTIONAL { ?s ex:propA ?a . OPTIONAL { ?a ex:label ?labelA . } BIND ( IF ( BOUND (?labelA), ?labelA, ?a) as ?valueA) } }
      Execution time (ms): 110922
      Execution time (ms): 41004
      

      Attachments

        1. GenerateTestDataset.java
          3 kB
          Mark Buquor
        2. ExecuteTestQueries.java
          3 kB
          Mark Buquor

        Issue Links

          Activity

            People

              andy Andy Seaborne
              mark.buquor@us.ibm.com Mark Buquor
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: