Commit 342557b0 authored by Pedro Pombeiro's avatar Pedro Pombeiro Committed by Adam Hegyi

Add additional index for reverse sorting order

parent 5049097d
......@@ -8,13 +8,13 @@ class AddRunnersCreatedAtIndex < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
INDEX_NAME = 'index_ci_runners_on_created_at_and_id'
def up
add_concurrent_index :ci_runners, [:created_at, :id], name: INDEX_NAME
add_concurrent_index :ci_runners, [:created_at, :id], order: { id: :desc }, name: 'index_ci_runners_on_created_at_and_id_desc'
add_concurrent_index :ci_runners, [:created_at, :id], order: { created_at: :desc, id: :desc }, name: 'index_ci_runners_on_created_at_desc_and_id_desc'
end
def down
remove_concurrent_index :ci_runners, [:created_at, :id], name: INDEX_NAME
remove_concurrent_index :ci_runners, [:created_at, :id], order: { id: :desc }, name: 'index_ci_runners_on_created_at_and_id_desc'
remove_concurrent_index :ci_runners, [:created_at, :id], order: { created_at: :desc, id: :desc }, name: 'index_ci_runners_on_created_at_desc_and_id_desc'
end
end
......@@ -9,16 +9,17 @@ class ReplaceRunnersContactedAtIndex < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
OLD_INDEX_NAME = 'index_ci_runners_on_contacted_at'
NEW_INDEX_NAME = 'index_ci_runners_on_contacted_at_and_id'
def up
add_concurrent_index :ci_runners, [:contacted_at, :id], name: NEW_INDEX_NAME, using: 'btree'
add_concurrent_index :ci_runners, [:contacted_at, :id], order: { id: :desc }, name: 'index_ci_runners_on_contacted_at_and_id_desc', using: 'btree'
add_concurrent_index :ci_runners, [:contacted_at, :id], order: { contacted_at: :desc, id: :desc }, name: 'index_ci_runners_on_contacted_at_desc_and_id_desc', using: 'btree'
remove_concurrent_index_by_name :ci_runners, OLD_INDEX_NAME
end
def down
remove_concurrent_index_by_name :ci_runners, NEW_INDEX_NAME
remove_concurrent_index_by_name :ci_runners, 'index_ci_runners_on_contacted_at_and_id_desc'
remove_concurrent_index_by_name :ci_runners, 'index_ci_runners_on_contacted_at_desc_and_id_desc'
add_concurrent_index :ci_runners, :contacted_at, name: OLD_INDEX_NAME, using: 'btree'
end
......
......@@ -22904,9 +22904,13 @@ CREATE INDEX index_ci_runner_projects_on_project_id ON ci_runner_projects USING
CREATE INDEX index_ci_runner_projects_on_runner_id ON ci_runner_projects USING btree (runner_id);
CREATE INDEX index_ci_runners_on_contacted_at_and_id ON ci_runners USING btree (contacted_at, id);
CREATE INDEX index_ci_runners_on_contacted_at_and_id_desc ON ci_runners USING btree (contacted_at, id DESC);
CREATE INDEX index_ci_runners_on_created_at_and_id ON ci_runners USING btree (created_at, id);
CREATE INDEX index_ci_runners_on_contacted_at_desc_and_id_desc ON ci_runners USING btree (contacted_at DESC, id DESC);
CREATE INDEX index_ci_runners_on_created_at_and_id_desc ON ci_runners USING btree (created_at, id DESC);
CREATE INDEX index_ci_runners_on_created_at_desc_and_id_desc ON ci_runners USING btree (created_at DESC, id DESC);
CREATE INDEX index_ci_runners_on_description_trigram ON ci_runners USING gin (description gin_trgm_ops);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment