Hello, and my first post here :)
For medium-size queries which timeout in a SPARQL endpoint, you can add these clauses and it sometimes gives a result:
ORDER BY RAND() LIMIT 100
You will only obtain some results with no specific order, but it is better than nothing. It doesn’t work everytime, but it works more often than without it or with only a limit. Given it is a hacky technique, it should be the last thing to try, after other query optimisations.
For instance, when I search all elements with a GND ID (P227) without P31 neither P279, I get a timeout even when I only add a limit. When I add these two clauses, I get a result.
Cheers, ~ Seb35
With rand: https://query.wikidata.org/#SELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%3F...
Without rand: https://query.wikidata.org/#SELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%3F...