Whenever I run into a timeout, the first thing I do is remove the " "SERVICE wikibase:label { bd:serviceParam wikibase:language "en"}" from the query. Often replacing that for statements with rdfs:label and schema:description, plus the equivalent language filers. I adapted you query accordingly and got results:

https://query.wikidata.org/#SELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%3FitemDescription%0AWHERE%0A%7B%0A%09%3Fitem%20wdt%3AP227%20%3Fx%20.%0A%20%20%20%20MINUS%20%7B%20%3Fitem%20wdt%3AP31%20%3Fy%20%7D%0A%09MINUS%20%7B%20%3Fitem%20wdt%3AP279%20%3Fz%20%7D%0A%20%20%20%20%3Fitem%20rdfs%3Alabel%20%3FitemLabel%20.%0A%20%20%20%20%3Fitem%20schema%3Adescription%20%3FitemDescription%0A%20%20%20%20FILTER%20%28lang%28%3FitemLabel%29%20%3D%20%22en%22%29%0A%20%20%20%20FILTER%20%28lang%28%3FitemDescription%29%20%3D%20%22en%22%29%0A%7D%0ALIMIT%20100

Cheers,

Andra



On Sat, Jun 18, 2016 at 8:22 PM, Seb35 <seb35wikipedia@gmail.com> wrote:
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%3FitemDescription%0AWHERE%0A%7B%0A%09%3Fitem%20wdt%3AP227%20%3Fx%20.%0A%20%20%20%20MINUS%20%7B%20%3Fitem%20wdt%3AP31%20%3Fy%20%7D%0A%09MINUS%20%7B%20%3Fitem%20wdt%3AP279%20%3Fz%20%7D%0A%20%20%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%7D%0A%7D%0AORDER%20BY%20RAND%28%29%0ALIMIT%20100

Without rand:
https://query.wikidata.org/#SELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%3FitemDescription%0AWHERE%0A%7B%0A%09%3Fitem%20wdt%3AP227%20%3Fx%20.%0A%20%20%20%20MINUS%20%7B%20%3Fitem%20wdt%3AP31%20%3Fy%20%7D%0A%09MINUS%20%7B%20%3Fitem%20wdt%3AP279%20%3Fz%20%7D%0A%20%20%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%7D%0A%7D%0ALIMIT%20100

_______________________________________________
Wikidata mailing list
Wikidata@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata