Update:
The following query
SELECT (COUNT(?x) as ?cx) WHERE { { SELECT ?x WHERE {?x ?p ?y.} LIMIT 1 } }
gives 20,853,874,240 on Wikidata QLever endpoint. It should give 1.
The behaviour was initially observed on the Uniprot QLever endpoint, but it carries over to Wikidata QLever, as well.
Original formulation:
The following query does not give the results immediately, as it most likely would be expected to.
SELECT (COUNT(?x) as ?cx) WHERE {
{ SELECT ?x WHERE {?x a <http://purl.uniprot.org/core/Gene>. } LIMIT 1 }
?x a ?y. }
If counting is not done on the outermost level, behavior is much more reasonable, even for higher limits.
This is observed on the Uniprot QLever dataset.