Details

      Description

      When using query like this:

      #  Query to find the most common values for the property ?prop
       #  on items either in the class ?class or a first-level subclass of it
       #  when ?class = Q3305213 and ?prop = P136
       #  Query generated by [[Template:TopListDepth2]]
       
      SELECT ?value ?valueLabel ?count WHERE {
        {
          SELECT ?value (COUNT(DISTINCT ?a) AS ?count) WHERE {
             ?a ?prop ?value . 
             ?a wdt:P31/wdt:P279? ?class .
             BIND (wdt:P136 AS ?prop) .
             BIND (wd:Q3305213 AS ?class) .
          } GROUP BY ?value
        } . 
        SERVICE wikibase:label {
          bd:serviceParam wikibase:language "en" . 
        }
      }
      # HAVING (?count > 1)        ### use this to show only repeated values
      ORDER BY DESC(?count) ?valueLabel
      LIMIT 200
      

      it takes about 12-13 seconds to run. However, if we manually substitute constants, like this:

      #  Query to find the most common values for the property ?prop
       #  on items either in the class ?class or a first-level subclass of it
       #  when ?class = Q3305213 and ?prop = P136
       #  Query generated by [[Template:TopListDepth2]]
       
      SELECT ?value ?valueLabel ?count WHERE {
        {
          SELECT ?value (COUNT(DISTINCT ?a) AS ?count) WHERE {
             ?a wdt:P136 ?value . 
             ?a wdt:P31/wdt:P279? wd:Q3305213 .
          } GROUP BY ?value
        } . 
        SERVICE wikibase:label {
          bd:serviceParam wikibase:language "en" . 
        }
      }
      # HAVING (?count > 1)        ### use this to show only repeated values
      ORDER BY DESC(?count) ?valueLabel
      LIMIT 200
      

      It runs in between 1 and 2 seconds. Looks like the query engine fails to propagate the constant values, may be part of BLZG-1141.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              michaelschmidt michaelschmidt
              Reporter:
              stasmalyshev stasmalyshev
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: