Skip to content

Extend AddOnAssignedUsersFinder to support historical data queries with PG

Summary

The AddOnAssignedUsersFinder class currently only supports historical data retrieval when ClickHouse (CH) is enabled. This functionality should be extended to also work with PostgreSQL as the backend database.

The data to support the finder on PG is available at subscription_user_add_on_assignment_versions. We need support index(es) to be able to retrieve historical data:

CREATE INDEX idx_sub_user_addon_create_purchase_time_user
ON subscription_user_add_on_assignment_versions (purchase_id, created_at, user_id)
WHERE event = 'create';

and

CREATE INDEX idx_sub_user_addon_destroy_item_user_time
ON subscription_user_add_on_assignment_versions (item_id, user_id, created_at)
WHERE event = 'destroy';

Sample query: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/44966/commands/138011.

Edited by 🤖 GitLab Bot 🤖