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

Adding constant projection to query ruins performance

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: BLAZEGRAPH_2_1_4
    • Fix Version/s: None
    • Component/s: Wikidata Query Service
    • Labels:
      None

      Description

      I try this query:

      SELECT ?id (COUNT(?id) AS ?count) WHERE {
        ?i wdt:P31 ?id.
      }
      GROUP BY ?id
      ORDER BY DESC(?count)
      LIMIT 20
      

      Which calculates top 20 items used with property P31, and it works just
      fine, under 1 second. However, if I add a static projection to it:

      SELECT ?id (COUNT(?id) AS ?count) ("x" as ?x) WHERE {
        ?i wdt:P31 ?id.
      }
      GROUP BY ?id
      ORDER BY DESC(?count)
      LIMIT 20
      

      it times out. Something is clearly wrong here.

      The plans for the queries are very different:
      https://gist.github.com/smalyshev/d5d3d436bf49b554c89b94ffa23258be

      I'm not sure why adding a constant into projection changes the plans so
      much.

      Disabling the optimizer does not seem to help. Same problem happens if I
      do something like this:

      SELECT ?id (COUNT(?id) AS ?count) ?x WHERE {
        ?i wdt:P31 ?id.
        BIND("x" as ?x)
      }
      GROUP BY ?id ?x
      ORDER BY DESC(?count)
      LIMIT 20
      

      This query:

      SELECT ?id ?count ("x" as ?x) WHERE {
      {
      SELECT ?id (COUNT(?id) AS ?count) WHERE {
        ?i wdt:P31 ?id.
      }
      GROUP BY ?id ?x
      ORDER BY DESC(?count)
      LIMIT 20
      }
      }
      

      is slightly faster - 18 seconds - but way slower than original one,
      under 1 sec. Converting ?x to BIND or VALUES and using various hints
      don't seem to change anything (though VALUES seem to do it in 15s - a
      bit faster, but still nowhere near proper performance).

        Attachments

          Activity

            People

            Assignee:
            beebs Brad Bebee
            Reporter:
            stasmalyshev stasmalyshev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: