Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run a single query for pre-loading VimPerformanceStates
This bug was introduced by ManageIQ#22579 I misread this code and thought it was fetching all records a single time. Turns out it is running this query N+1 times. So adding the extra resource_id values (and a large count at that) to each query, means we still run N+1, we fetch the same number of records, but our query is much larger After ===== We are running a single query to fetch all VimPerformanceStates Details ======= One fix would have been to add a `load`, but that depends upon our preloader monkey patch: ManageIQ#22594 The number of queries are the same, the index usage is the same, the number of rows returned is the same for unchanged, load, and not specifying the resource But the PR in question does double the size of the query string. Which is a problem when rolling up a container image from a bunch of containers. I opted to change the code rather than rollback because I liked the extra comments around the block of code. In the future, we want to consolidate the caching of vim_performance_states as we currently have 2 methods of caching those values: - preload that association - store in an @ variable. Numbers ======= | ms |query | qry ms | rows |` comments` | ---:| ---:| ---:| ---:| --- | 4,808.1 | 19 | 2,736.4 | 1,334 |` 340-2023-06-22 20:00:00Z-long-1#before` | 130.2 | 1 | 130.2 | |`. SELECT vim_performance_states.* -- [30991]` | ---:| ---:| ---:| ---:| --- | 4,431.2 | 19 | 2,500.3 | 1,334 |` 340-2023-06-22 20:00:00Z-short-1#after` | 82.6 | 1 | 82.5 | |`. SELECT vim_performance_states.* -- [15036]` | ---:| ---:| ---:| ---:| --- | 4,659.0 | 19 | 2,690.4 | 1,334 |` 340-2023-06-22 20:00:00Z-load-1#alt` | 107.9 | 1 | 107.9 | |`. SELECT vim_performance_states.* -- [15036]` alt being to use load instead of removing resource from the query
- Loading branch information