I’ve been doing some benchmarking on my Ryzen 7 2700X. I don’t know how that compares to what you’re running the site on, but I hope it will still be useful.
derpibooru=# select count(*) from users;
count
--------
462186
(1 row)
Time: 21.599 ms
There are 462k users on the site.
derpibooru=# select count( distinct tag_changes.image_id ) as image_count, users.name
from tag_changes
join users on tag_changes.user_id = users.id
group by users.name
order by image_count desc
limit 20;
image_count | name
-------------+--------------------
2021969 | Dragonpone
727405 | Zeb
404496 | deactivateda0841fe
333667 | GlitchedWolf
261694 | Princess Luna
236625 | LightningBolt
224932 | Paws359
189831 | Ereiam
189221 | JP
151202 | 971384265
124257 | 🙂
123776 | saby
113768 | Mildgyth
104096 | WatermelonRat
99124 | patec
96985 | Markiz93
90304 | Defender of 5
89030 | ZONESS
80520 | Crow
73005 | stsyn
(20 rows)
Time: 19999.431 ms (00:19.999)
Out of these, 14 users have changed tags on more than 100k images.
Clear winner here is Dragonpone with over 2M changed images. Congratulations!
derpibooru=# select count( distinct tag_changes.image_id )
from tag_changes
join users on tag_changes.user_id = users.id
join tags on tag_changes.tag_id = tags.id
where users.name = 'Dragonpone' and tags.name = 'g4';
count
---------
1979766
(1 row)
Time: 737.473 ms
…almost all of which are for “g4”.
derpibooru=# select count( distinct tag_changes.image_id )
from tag_changes
join users on tag_changes.user_id = users.id
join tags on tag_changes.tag_id = tags.id
where users.name = 'Dragonpone' and tags.name <> 'g4';
count
--------
177068
(1 row)
Time: 3359.351 ms (00:03.359)
But there are still 177k images affected by other tag changes. Not bad. But we’re getting distracted.
So how long does it take to count the total number of images affected by the tag changes of a given user? We know what the worst case is going to be.
derpibooru=# select count( distinct tag_changes.image_id ) as image_count, users.name
from tag_changes
join users on tag_changes.user_id = users.id
where users.name = 'Dragonpone'
group by users.name;
image_count | name
-------------+------------
2021969 | Dragonpone
(1 row)
Time: 1169.377 ms (00:01.169)
Ouch. Over a second. But we can consider this a pathological case. What about the next one in the list?
derpibooru=# select count( distinct tag_changes.image_id ) as image_count, users.name
from tag_changes
join users on tag_changes.user_id = users.id
where users.name = 'Zeb'
group by users.name;
image_count | name
-------------+------
727405 | Zeb
(1 row)
Time: 647.426 ms
Still not great, but also not a disaster. And image_count is decreasing quickly for the next couple of users. Now what if we ignore the 0.003% of users that have touched more than 100k images? #15 on the list:
derpibooru=# select count( distinct tag_changes.image_id ) as image_count, users.name
from tag_changes
join users on tag_changes.user_id = users.id
where users.name = 'patec'
group by users.name;
image_count | name
-------------+-------
99124 | patec
(1 row)
Time: 101.447 ms
Page generation time as reported in the footer of the site is around 350ms to 400ms for me when browsing images on the site, so I guess this should be fine already.
And for more average users
derpibooru=# select count( distinct tag_changes.image_id ) as image_count, users.name
from tag_changes
join users on tag_changes.user_id = users.id
where users.name = '.'
group by users.name;
image_count | name
-------------+------
815 | .
(1 row)
Time: 2.399 ms
So if you look at the top ten busiest taggers on the site, it might take a few hundred ms. For 99.997% of the users it should be perfectly fine.