Over the weekend, we had issues due to scrapers being aggressive with wikidata and while the increased number of requests wasn't that big, the increased load on the appservers were quite noticeable (See this).
I've been trying to see how we could make wikidata less heavy and found a decent number of db queries for a small item (picked via Special:Random):
- https://logstash.wikimedia.org/app/dashboards#/doc/logstash-*/logstash-mediawiki-1-7.0.0-1-2026.06.08?id=wg15qJ4B7Wauj1RhVs5X
- https://logstash.wikimedia.org/app/dashboards#/doc/logstash-*/logstash-mediawiki-1-7.0.0-1-2026.06.08?id=uw15qJ4B7Wauj1RhVs5X
- https://logstash.wikimedia.org/app/dashboards#/doc/logstash-*/logstash-mediawiki-1-7.0.0-1-2026.06.08?id=qQ15qJ4B7Wauj1RhVs5X
- https://logstash.wikimedia.org/app/dashboards#/doc/logstash-*/logstash-mediawiki-1-7.0.0-1-2026.06.08?id=og15qJ4B7Wauj1RhVs5X
- https://logstash.wikimedia.org/app/dashboards#/doc/logstash-*/logstash-mediawiki-1-7.0.0-1-2026.06.08?id=mw15qJ4B7Wauj1RhVs5X
- https://logstash.wikimedia.org/app/dashboards#/doc/logstash-*/logstash-mediawiki-1-7.0.0-1-2026.06.08?id=lg15qJ4B7Wauj1RhVs5X
- https://logstash.wikimedia.org/app/dashboards#/doc/logstash-*/logstash-mediawiki-1-7.0.0-1-2026.06.08?id=jw15qJ4B7Wauj1RhVs5X
and if you look at the excimer profiler, this is the where they are coming from:
Basically, we try to cache the terms to reduce db load but the cache key has the revision id to invalidate the cache in case of updates and that leads to revision id being looked up a lot:
Wikibase\Lib\Store\Sql\PageTableEntityQueryBase::selectRows [0.512ms] [1 rows] db1178: SELECT rev_id,rev_timestamp,page_latest,page_is_redirect,page_title FROM `page` JOIN `revision` ON ((page_latest=rev_id)) WHERE (((page_title = 'P31' AND page_namespace = 120)));
In that profile, it takes only 2% of the load time but I can imagine in larger items, it'll start to add up.
Caching rev id of properties for an hour could save a lot of db lookups and make us more resilient towards scrapers.
