Skip to content

Remove redundant index on creator_id and created_at from projects

What does this MR do?

Removes redundant index index_projects_on_creator_id_and_created_at from projects table. As discussed in !29148 (comment 323356080) this is the follow-up MR.

At the moment we have these indexes:

CREATE INDEX index_projects_on_created_at_and_id ON public.projects USING btree (created_at, id);

CREATE INDEX index_projects_on_creator_id_and_created_at ON public.projects USING btree (creator_id, created_at);

CREATE INDEX index_projects_on_creator_id_and_created_at_and_id ON public.projects USING btree (creator_id, created_at, id);

The last one makes the middle one redundant. This MR deletes it.

Migration output

up

rake db:migrate:up VERSION=20200414144547  
== 20200414144547 RemoveIndexProjectsOnCreatorIdAndCreatedAtFromProjects: migrating 
-- transaction_open?()
   -> 0.0000s
-- indexes(:projects)
   -> 0.0135s
-- execute("SET statement_timeout TO 0")
   -> 0.0001s
-- remove_index(:projects, {:algorithm=>:concurrently, :name=>"index_projects_on_creator_id_and_created_at"})
   -> 0.0020s
-- execute("RESET ALL")
   -> 0.0001s
== 20200414144547 RemoveIndexProjectsOnCreatorIdAndCreatedAtFromProjects: migrated (0.0158s) 

down

 rake db:migrate:down VERSION=20200414144547
== 20200414144547 RemoveIndexProjectsOnCreatorIdAndCreatedAtFromProjects: reverting 
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:projects, [:creator_id, :created_at], {:name=>"index_projects_on_creator_id_and_created_at", :algorithm=>:concurrently})
   -> 0.0132s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- add_index(:projects, [:creator_id, :created_at], {:name=>"index_projects_on_creator_id_and_created_at", :algorithm=>:concurrently})
   -> 0.0031s
-- execute("RESET ALL")
   -> 0.0001s
== 20200414144547 RemoveIndexProjectsOnCreatorIdAndCreatedAtFromProjects: reverted (0.0167s) 

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Relates #213800 (closed)

Edited by Alina Mihaila

Merge request reports