Skip to content

Adding (updated_at,id) index to bulk_import_entities

Max Fan requested to merge 432814-add-index-for-bulk-import-entity into master

What does this MR do and why?

Adding (updated_at,status) index to bulk_import_entities

This index helps with the scope .stale for BulkImports::Entity

Current Rails query:

[143] pry(main)> BulkImports::Entity.stale
  BulkImports::Entity Load (1.6ms)  SELECT "bulk_import_entities".* FROM "bulk_import_entities" WHERE (updated_at < '2023-11-29 19:45:19.445026') AND "bulk_import_entities"."status" IN (0, 1) /*application:console,db_config_name:main,console_hostname:MaxPro.lan,console_username:maxfan,line:bin/rails:4:in `<main>'*/

Current database query:

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/24376/commands/77873

exec CREATE INDEX CONCURRENTLY "index_bulk_import_entities_on_updated_at_and_stale_status" ON "bulk_import_entities" ("updated_at", "id")WHERE status in (0, 1)
Session: webui-i24442
The query has been executed. Duration: 803.759 ms

After creating index database query:

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/24442/commands/78060

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.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #432814 (closed)

Edited by Max Fan

Merge request reports