Skip to content

Adding GIN index on name field of compliance frameworks table

Hitesh Raghuvanshi requested to merge 434946-add-gin-index-compliance-name into master

What does this MR do and why?

Adding GIN index to name field of compliance_management_frameworks table as per the discussion in !138641 (comment 1686481286). This is to optimize the fuzzy_search on name field of the table added in !138641 (merged).

Migrations

#### up

bundle exec rake db:migrate:up:main VERSION=20231213112726
main: == [advisory_lock_connection] object_id: 182420, pg_backend_pid: 96832
main: == 20231213112726 AddTrigramIndexToComplianceManagementFrameworksOnName: migrating
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0952s
main: -- index_exists?(:compliance_management_frameworks, :name, {:name=>"index_compliance_management_frameworks_on_name_trigram", :using=>:gin, :opclass=>{:name=>:gin_trgm_ops}, :algorithm=>:concurrently})
main:    -> 0.0029s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0002s
main: -- add_index(:compliance_management_frameworks, :name, {:name=>"index_compliance_management_frameworks_on_name_trigram", :using=>:gin, :opclass=>{:name=>:gin_trgm_ops}, :algorithm=>:concurrently})
main:    -> 0.0112s
main: -- execute("RESET statement_timeout")
main:    -> 0.0002s
main: == 20231213112726 AddTrigramIndexToComplianceManagementFrameworksOnName: migrated (0.1211s)

main: == [advisory_lock_connection] object_id: 182420, pg_backend_pid: 96832

################################################################################

#### down

bundle exec rake db:migrate:down:main VERSION=20231213112726
main: == [advisory_lock_connection] object_id: 182100, pg_backend_pid: 96379
main: == 20231213112726 AddTrigramIndexToComplianceManagementFrameworksOnName: reverting
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0883s
main: -- indexes(:compliance_management_frameworks)
main:    -> 0.0027s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0001s
main: -- remove_index(:compliance_management_frameworks, {:algorithm=>:concurrently, :name=>"index_compliance_management_frameworks_on_name_trigram"})
main:    -> 0.0020s
main: -- execute("RESET statement_timeout")
main:    -> 0.0001s
main: == 20231213112726 AddTrigramIndexToComplianceManagementFrameworksOnName: reverted (0.1058s)

main: == [advisory_lock_connection] object_id: 182100, pg_backend_pid: 96379

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 #434946 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports

Loading