Skip to content

Commit

Permalink
Add indexes to pictures table
Browse files Browse the repository at this point in the history
The Index will prevent temp tables if the user is searching for name or file_name. This is necessary if the table becomes bigger.
sascha-karnatz committed May 8, 2023
1 parent 415516f commit d272163
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions db/migrate/20230505132743_add_indexes_to_alchemy_pictures.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddIndexesToAlchemyPictures < ActiveRecord::Migration[6.1]
def change
add_index :alchemy_pictures, :name, if_not_exists: true
add_index :alchemy_pictures, :image_file_name, if_not_exists: true
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddIndexesToAlchemyPictures < ActiveRecord::Migration[6.1]
def change
add_index :alchemy_pictures, :name, if_not_exists: true
add_index :alchemy_pictures, :image_file_name, if_not_exists: true
end
end
4 changes: 3 additions & 1 deletion spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2023_01_23_105660) do
ActiveRecord::Schema[7.0].define(version: 2023_05_05_132743) do
create_table "alchemy_attachments", force: :cascade do |t|
t.string "name"
t.string "file_name"
@@ -202,6 +202,8 @@
t.integer "image_file_size"
t.string "image_file_format"
t.index ["creator_id"], name: "index_alchemy_pictures_on_creator_id"
t.index ["image_file_name"], name: "index_alchemy_pictures_on_image_file_name"
t.index ["name"], name: "index_alchemy_pictures_on_name"
t.index ["updater_id"], name: "index_alchemy_pictures_on_updater_id"
end

0 comments on commit d272163

Please sign in to comment.