After https://gerrit.wikimedia.org/r/#/c/259684/ is fully deployed (Thursday, January 14), we should set $wgSpecialGadgetUsageActiveUsers to false for English Wikipedia (since it's too expensive) in the wmf-config files and deploy the config change.
|operations/mediawiki-config : master||Disable active gadget user stats on enwiki since it takes too long|
|operations/mediawiki-config : master||Disable active user gadget stats on testwiki (in preparation for enwiki)|
One alternative mentioned by JCrespo in T120895#1875104 is to increase the time limit on the server. I'm not sure a lot of people would be supporting that.
I'd try and talk to Aaron and other folks to see if this query can be optimized better somehow to make it run faster.
In the meantime though we should turn it off because the query not running means that the Total users column won't be updated either. And new gadgets won't show up as well.
In theory, we could update it like we do other cached query pages