Add index for next_over_limit_check_at
What does this MR do and why?
As described in the issue for this MR we need an index to increase the efficiency of workers querying for the next namesapce detail to fetch. This MR adds that index as a post deploy migration. (I'm not confident that index creation will be quick enough on prod).
Follow-up for sync creation is here: Create the `index_next_over_limit_check_at_asc_... (#391830 - closed)
Screenshots or screen recordings
╰─% bundle exec rake db:migrate 14:43:03|neo|3.0.5
WARNING: This version of GitLab depends on gitlab-shell 14.17.0, but you're running 14.15.0. Please update gitlab-shell.
main: == 20230213103019 AddIndexForNextOverLimitCheckAt: migrating ==================
main: -- index_exists?("namespace_details", :next_over_limit_check_at, {:order=>{:next_over_limit_check_at=>"ASC NULLS FIRST"}, :name=>"index_next_over_limit_check_at_asc_order", :algorithm=>:concurrently})
main: -> 0.0019s
main: -- add_index_options("namespace_details", :next_over_limit_check_at, {:order=>{:next_over_limit_check_at=>"ASC NULLS FIRST"}, :name=>"index_next_over_limit_check_at_asc_order", :algorithm=>:concurrently})
main: -> 0.0003s
main: == 20230213103019 AddIndexForNextOverLimitCheckAt: migrated (0.1106s) =========
Timings
Before Index https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/15422/commands/53538
Time: 13.726 min
- planning: 5.967 ms
- execution: 13.726 min
- I/O read: 15.802 min
- I/O write: 0.000 ms
Shared buffers:
- hits: 21240345 (~162.10 GiB) from the buffer pool
- reads: 926521 (~7.10 GiB) from the OS file cache, including disk I/O
- dirtied: 86429 (~675.20 MiB)
- writes: 0
After Index https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/15422/commands/53609
Time: 21.863 ms
- planning: 5.459 ms
- execution: 16.404 ms
- I/O read: 15.859 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 6 (~48.00 KiB) from the buffer pool
- reads: 15 (~120.00 KiB) from the OS file cache, including disk I/O
- dirtied: 1 (~8.00 KiB)
- writes: 0
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.
Edited by Sam Figueroa