Track namespace IDs that enable duo chat
What does this MR do and why?
This MR tracks namespace IDs for request_duo_chat_response
internal event, which is outlined in this comment as:
%16.11: Going to add multiple IDs after Tracking namespace that empowered a user to use... (#438827 - closed) finished.
Related to https://gitlab.com/gitlab-org/gitlab/-/issues/452316+
Previous SQL query
SELECT
1 AS one
FROM
"namespaces"
INNER JOIN "members" ON "namespaces"."id" = "members"."member_namespace_id"
LEFT OUTER JOIN "gitlab_subscriptions" ON "gitlab_subscriptions"."namespace_id" = "namespaces".traversal_ids [1]
LEFT OUTER JOIN "plans" ON "plans"."id" = "gitlab_subscriptions"."hosted_plan_id"
INNER JOIN "namespace_settings" ON "namespace_settings"."namespace_id" = "namespaces".traversal_ids [1]
WHERE
"members"."user_id" = 1
AND "plans"."name" IN (
'silver',
'premium',
'premium_trial',
'gold',
'ultimate',
'ultimate_trial',
'ultimate_trial_paid_customer',
'opensource'
)
AND "namespace_settings"."experiment_features_enabled" = TRUE
LIMIT
1
Summary:
Time: 23.063 ms
- planning: 7.135 ms
- execution: 15.928 ms
- I/O read: 14.723 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 12 (~96.00 KiB) from the buffer pool
- reads: 12 (~96.00 KiB) from the OS file cache, including disk I/O
- dirtied: 1 (~8.00 KiB)
- writes: 0
Plan: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/27559/commands/85831
New SQL query
SELECT
DISTINCT traversal_ids [1]
FROM
"namespaces"
INNER JOIN "members" ON "namespaces"."id" = "members"."member_namespace_id"
LEFT OUTER JOIN "gitlab_subscriptions" ON "gitlab_subscriptions"."namespace_id" = "namespaces".traversal_ids [1]
LEFT OUTER JOIN "plans" ON "plans"."id" = "gitlab_subscriptions"."hosted_plan_id"
INNER JOIN "namespace_settings" ON "namespace_settings"."namespace_id" = "namespaces".traversal_ids [1]
WHERE
"members"."user_id" = 1
AND "plans"."name" IN (
'silver',
'premium',
'premium_trial',
'gold',
'ultimate',
'ultimate_trial',
'ultimate_trial_paid_customer',
'opensource'
)
AND "namespace_settings"."experiment_features_enabled" = TRUE
Summary:
Time: 1.290 s
- planning: 6.683 ms
- execution: 1.283 s
- I/O read: 1.269 s
- I/O write: 0.000 ms
Shared buffers:
- hits: 1486 (~11.60 MiB) from the buffer pool
- reads: 1045 (~8.20 MiB) from the OS file cache, including disk I/O
- dirtied: 7 (~56.00 KiB)
- writes: 0
Plan: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/27559/commands/85834
Please note that this is cached in Redis as user:<user-id>:group_ids_with_ai_chat_enabled
key, which will be evicted in 1 hour.
With hot cache:
Time: 12.389 ms
- planning: 8.008 ms
- execution: 4.381 ms
- I/O read: 0.000 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 2531 (~19.80 MiB) from the buffer pool
- reads: 0 from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
https://console.postgres.ai/gitlab/gitlab-production-main/sessions/27559/commands/85835
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.