As @Smalyshev points out in T204267#4581546, we’re sending a bunch of prefixes with each SPARQL query, even though they are probably already defined by default. We should try to avoid this, to reduce traffic to WDQS.
One complication is that we need to filter out statements with deprecated rank, and the IRIs of the “rank” predicate and the “Deprecated” node are different, depending on whether the query service is serving “munged” data (wikiba.se/ontology#) or not (wikiba.se/ontology-beta#). We currently do this by defining both wikibase and wikibase-beta prefixes explicitly, and removing deprecated statements using both prefixes, but that doesn’t work if we rely on the query service’ built-in notion of the wikibase prefix (which is always the non-beta version, regardless of whether the data went through the munger or not).
A simple solution, I suppose, would be to completely skip prefixes for REGEX queries, which are (I believe) the most common queries we send out and never need any prefixes.