qlever
qlever copied to clipboard
Predicate path with (^schema:about)? takes forever
The following query requires four minutes and a lot of memory. The runtime info shows a TRANSITIVE PATH operation costing 170 seconds, as well as a large UNION costing 60 seconds.
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX schema: <http://schema.org/>
SELECT ?x ?sitelinks WHERE {
?x wdt:P31 wd:Q5107 .
?x (^schema:about)?/wikibase:sitelinks ?sitelinks .
}
The following query, which replaces the ? via a UNION and the / via a temporary object, both in the natural way, finishes in a reasonable 13 seconds with a cold cache:
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX schema: <http://schema.org/>
SELECT ?x ?sitelinks WHERE {
?x wdt:P31 wd:Q5107 .
{ ?x wikibase:sitelinks ?sitelinks }
UNION
{ ?x ^schema:about ?tmp . ?tmp wikibase:sitelinks ?sitelinks }
}