Use the aggregated tables for duration chart
What does this MR do and why?
Note: the change is behind a feature flag, we plan to enable it for gitlab-org
shortly.
Within &6046 (closed), we're reworking how the date-range filter works in Value Stream Analytics. Implementing the new behaviour was impractical using the existing finders (MergeRequestFinder and IssuesFinder) because the date range query could be pointed to arbitrary timestamp columns. The new approach uses aggregated tables where timestamp data is ready to be queried.
This MR re-implements the query for the Value Stream Analytics duration chart to use the new aggregated tables. The query logic is quite similar to the original one, the queried tables are different.
The duration chart feature (available on group-level, ultimate or premium):
Query plan
- New (aggregated)
- https://explain.depesz.com/s/SPnP
- Uncached timing is <300ms on db-lab
- Old (current)
- https://explain.depesz.com/s/qQdp
- Uncached timing is 14s on db-lab
Since we query different kinds of data the count does not need to match.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
How to test it
- Enable the feature
Feature.enable(:use_vsa_aggregated_tables)
- Seed a new VSA project
SEED_CYCLE_ANALYTICS=true SEED_VSA=true FILTER=cycle_analytics rake db:seed_fu
- The seed script prints the project path, copy it and navigate to the project.
- Go to the group.
- Go to Analytics > Value Stream
- Open the top right dropdown and
Create new Value Stream
- Add a name and save.
- Start rails console and aggregate the data
group = Group.find(x) Analytics::CycleAnalytics::DataLoaderService.new(group:group, model: Issue).execute Analytics::CycleAnalytics::DataLoaderService.new(group:group, model: MergeRequest).execute
- Load the VSA page again.
- Inspecting the
duration_-_chart
endpoint requests, we should see that the_stage_events
tables are being used.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #344802 (closed)