Show original queries in QueryRecorder output

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Right now we're showing the queries that were executed, with a counter. But sometimes it's not clear that a query was executed multiple times as discussed with @jamedjo in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/5807#note_111756065.

I suggest we show the original queries in the output as well, that way it's easier to determine which queries are made on top of the original ones.

Example:

Before:

       Expected a maximum of 4 queries, got 12:

       Extra queries:
       [1] SELECT "user_statuses".* FROM "user_statuses" WHERE "user_statuses"."user_id" IN (2, 3, 4, 5, 6)
       [1] SELECT "u2f_registrations".* FROM "u2f_registrations" WHERE "u2f_registrations"."user_id" IN (2, 3, 4, 5, 6)
       [4] SELECT  "saml_providers".* FROM "saml_providers" WHERE "saml_providers"."group_id" = $1 LIMIT 1
       [4] SELECT COUNT(*) FROM "identities" WHERE "identities"."user_id" = $1 AND ("identities"."saml_provider_id" IS NOT NULL) AND "identities"."saml_provider_id" = 1

After:

       Expected a maximum of 4 queries, got 12:

       Extra queries:
       [1] SELECT "user_statuses".* FROM "user_statuses" WHERE "user_statuses"."user_id" IN (2, 3, 4, 5, 6)
       [1] SELECT "u2f_registrations".* FROM "u2f_registrations" WHERE "u2f_registrations"."user_id" IN (2, 3, 4, 5, 6)
       [4] SELECT  "saml_providers".* FROM "saml_providers" WHERE "saml_providers"."group_id" = $1 LIMIT 1
       [4] SELECT COUNT(*) FROM "identities" WHERE "identities"."user_id" = $1 AND ("identities"."saml_provider_id" IS NOT NULL) AND "identities"."saml_provider_id" = 1

       Original queries:
       [1] SELECT "user_statuses".* FROM "user_statuses" WHERE "user_statuses"."user_id" IN (2, 3, 4, 5, 6)
       [1] SELECT "u2f_registrations".* FROM "u2f_registrations" WHERE "u2f_registrations"."user_id" IN (2, 3, 4, 5, 6)
       [1] SELECT  "saml_providers".* FROM "saml_providers" WHERE "saml_providers"."group_id" = $1 LIMIT 1
       [1] SELECT COUNT(*) FROM "identities" WHERE "identities"."user_id" = $1 AND ("identities"."saml_provider_id" IS NOT NULL) AND "identities"."saml_provider_id" = 1
Edited Sep 28, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading