Steps to replicate the issue (include links if applicable):
- Perform API query for logevents for a user with many log actions but without recent activity, e.g. https://en.wikipedia.org/w/api.php?action=query&list=logevents&leprop=timestamp&ledir=older&leuser=ST47&lelimit=1 (to chose a random prolific editor without any recent logged actions)
What happens?:
Query either takes 20+ seconds to resolve, or it times out with an internal_api_error_DBQueryTimeoutError error.
What should have happened instead?:
Query should resolve in a few seconds, like https://en.wikipedia.org/w/index.php?title=Special:Log/ST47&limit=1 does.
Other information (browser name/version, screenshots, etc.):
Raised at https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)#Logevents_API_slow_for_inactive_users%3F
Per @Cryptic and @Anomie in that VPT thread, while Special:Log uses the log_actor_time index, API queries (as well as quarry queries such as https://quarry.wmcloud.org/query/97383) are just searching through the log_times index. Adding an letype, e.g. letype=block, does seem to force it to use the log_actor_type_time index which returns results almost instantly.
T71222 was reporting this same issue back in 2019, but the workaround that resolved that bug was undone in 2021 in https://gerrit.wikimedia.org/r/q/I9198c29a. T303089 reported the same issue for Special:Log, but that fix didn't seem to apply to API or quarry queries.