| Lucas_Werkmeister_WMDE added a comment. |
Here’s an example query:
SELECT ?entity ?entityLabel (COUNT(?statement) AS ?count) WHERE {
hint:Query hint:optimizer "None".
?statement wikibase:rank wikibase:DeprecatedRank.
?entity ?p ?statement.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?entity ?entityLabel
HAVING(?count > 10)
ORDER BY DESC(?count)
LIMIT 100
OFFSET 0The HAVING and OFFSET modifiers are somewhat artificial (I added them to have a complete example), but apart from that, this is a real, useful query (entities with most deprecated statements).
Here’s the optimized version:
SELECT ?entity ?entityLabel ?count WITH { SELECT ?entity (COUNT(?statement) AS ?count) WHERE { hint:Query hint:optimizer "None". ?statement wikibase:rank wikibase:DeprecatedRank. ?entity ?p ?statement. } GROUP BY ?entity ?entityLabel HAVING(?count > 10) ORDER BY DESC(?count) LIMIT 100 OFFSET 0 } AS %results WHERE { INCLUDE %results. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } ORDER BY DESC(?count)
- The inner SELECT clause consists of the original one, but with all Label variables removed.
- The outer SELECT clause consists of all the variables of the original one, but without expressions (e. g. just ?count).
- Of the solution modifiers,
- GROUP BY, HAVING, LIMIT and OFFSET are only present on the inner query, and
- ORDER BY is present on both queries.
Of course, this optimization should work with or without explicit rdfs:label parameters for the label service, so it’s probably best to implement this as a separate optimizer which runs after the one that imports rdfs:label parameters from the SELECT clause.
TASK DETAIL
EMAIL PREFERENCES
To: Lucas_Werkmeister_WMDE
Cc: Smalyshev, Aklapper, Lucas_Werkmeister_WMDE, Jonas, GoranSMilovanovic, QZanden, EBjune, merbst, Avner, debt, Gehel, FloNight, Xmlizer, Izno, jkroll, Wikidata-bugs, Jdouglas, aude, Tobias1984, Manybubbles, Mbch331
Cc: Smalyshev, Aklapper, Lucas_Werkmeister_WMDE, Jonas, GoranSMilovanovic, QZanden, EBjune, merbst, Avner, debt, Gehel, FloNight, Xmlizer, Izno, jkroll, Wikidata-bugs, Jdouglas, aude, Tobias1984, Manybubbles, Mbch331
_______________________________________________ Wikidata-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs
