Lucas_Werkmeister_WMDE added a comment.

I found a workaround by poking around the query hints:

# items with most statements
SELECT ?item ?itemLabel ?statements WHERE {
  ?item wikibase:statements ?statements. hint:Prior hint:rangeSafe true.
  FILTER(?statements >= 1000)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?statements)
LIMIT 10

With the rangeSafe hint (see documentation – “push range filter down onto an index”, which we can do because our predicates are, unknown value aside, strongly typed), the FILTER suddenly becomes magically efficient, and the whole query completes in a few hundred milliseconds. Unfortunately, this requires the FILTER, with some value that you assume won’t actually limit the results (i. e., you assume the top ten results have well above 1000 statements) – apparently the ORDER BY + LIMIT combination isn’t something that BlazeGraph “pushes down” similarly.


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

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

To: Lucas_Werkmeister_WMDE
Cc: Aklapper, Smalyshev, Lucas_Werkmeister_WMDE, Lahi, GoranSMilovanovic, QZanden, EBjune, merbst, Avner, debt, Gehel, Jonas, FloNight, Xmlizer, jkroll, Wikidata-bugs, Jdouglas, aude, Tobias1984, Manybubbles, Mbch331
_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to