Skip to content

Perform a limited count for the badge counts for tabs in the Users admin area

Robert Speicher requested to merge rs-remove-admin-user-badge-counts into master

In a development environment with 2.5 million users (i.e., gitlab.com scale), this took the page time from 7000ms down to 900ms when paginating all of the users, and less than 1ms when the grouping being paginated is small (such as Admins).

Example of queries before this change (in development):

1797.448ms	SELECT COUNT(*) FROM "users" LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id WHERE (u2f.id IS NULL AND otp_required_for_login = 'f')
1731.98ms	SELECT DISTINCT COUNT(DISTINCT "users"."id") FROM "users" LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id WHERE (u2f.id IS NOT NULL OR otp_required_for_login = 't')
917.99ms	SELECT COUNT(*) FROM "users" WHERE ("users"."state" IN ('active')) AND (ghost IS NOT TRUE)
890.916ms	SELECT COUNT(*) FROM "users" WHERE "users"."external" = $1
760.698ms	SELECT COUNT(*) FROM "users" WHERE (id NOT IN (SELECT DISTINCT(user_id) FROM members WHERE user_id IS NOT NULL AND requested_at IS NULL))

image

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/33927

Edited by Robert Speicher

Merge request reports