Lucas_Werkmeister_WMDE added a comment.

  Considering this example query 
<https://query.wikidata.org/#SELECT%20DISTINCT%20?item%20?itemLabel%20WHERE%20%7B%0A%20%20SERVICE%20wikibase:label%20%7B%20bd:serviceParam%20wikibase:language%20%22%5BAUTO_LANGUAGE%5D%22.%20%7D%0A%20%20%7B%0A%20%20%20%20SELECT%20DISTINCT%20?item%20WHERE%20%7B%0A%20%20%20%20%20%20?item%20p:P31%20?statement0.%0A%20%20%20%20%20%20?statement0%20(ps:P31/(wdt:P279*))%20wd:Q146.%0A%20%20%20%20%20%20?item%20p:P18%20?statement1.%0A%20%20%20%20%20%20?statement1%20(ps:P18)%20_:anyValueP18.%0A%20%20%20%20%7D%0A%20%20%20%20LIMIT%20100%0A%20%20%7D%0A%7D>
 generated by the query builder:
  
    SELECT DISTINCT ?item ?itemLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language 
"[AUTO_LANGUAGE]". }
      {
        SELECT DISTINCT ?item WHERE {
          ?item p:P31 ?statement0.
          ?statement0 (ps:P31/(wdt:P279*)) wd:Q146.
          ?item p:P18 ?statement1.
          ?statement1 (ps:P18) _:anyValueP18.
        }
        LIMIT 100
      }
    }
  
  I see three possible improvements:
  
  - Move the label service //below// the subquery with the actual substance. 
This makes sense semantically as well: the query service is expected to first 
get the items and then their labels. Should be very doable.
  - Drop the intermediate `?statement` variables if they’re only used once 
(i.e. the references mode is “with and without references”). `?item 
p:P31/ps:P31/wdt:P279* wd:Q146.` Might be a bit trickier, but should be doable.
  - Remove redundant parentheses – `(ps:P31/(wdt:P279*))` is equivalent to 
`ps:P31/wdt:P279*`. This is partially up to the SPARQL.js library; that said, 
the `(ps:P18)` is strange (we can see in `p:P31` that SPARQL.js is sometimes 
willing to omit the parentheses), so there might be something we can do to at 
least remove that.

TASK DETAIL
  https://phabricator.wikimedia.org/T291977

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Lucas_Werkmeister_WMDE
Cc: Lucas_Werkmeister_WMDE, Aklapper, Lydia_Pintscher, Invadibot, maantietaja, 
Akuckartz, Iflorez, alaa_wmde, Nandana, Lahi, Gq86, GoranSMilovanovic, QZanden, 
LawExplorer, _jensen, rosalieper, Scott_WUaS, Wikidata-bugs, aude, Mbch331
_______________________________________________
Wikidata-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to