Using the following query on a small dataset (libraries in an Italian region)
SELECT DISTINCT ?item WHERE { ?item (wdt:P131/wdt:P131*) wd:Q1284. ?item (wdt:P31/wdt:P279*) wd:Q7075. }
I get a timeout using Wikidata Query Service or the error message
#TOOL: legacy code failed in /data/project/magnustools/public_html/php/ToolforgeCommon.php on line 425
using a Wikidata List template. On the contrary, the query works using a named subquery
SELECT ?item with { select ?item where { ?item (wdt:P131/wdt:P131*) wd:Q1284. } } as %i where { include %i ?item (wdt:P31/wdt:P279*) wd:Q7075. }
or a different instance (museums instead of libraries)
SELECT DISTINCT ?item WHERE { ?item (wdt:P131/wdt:P131*) wd:Q1284. ?item (wdt:P31/wdt:P279*) wd:Q33506. }
or a different similar region
SELECT DISTINCT ?item WHERE { ?item (wdt:P131/wdt:P131*) wd:Q1279. ?item (wdt:P31/wdt:P279*) wd:Q7075. }
Is it a bug?
Thanks, Pietro