Skip to content

Commit

Permalink
Index generic_events#type
Browse files Browse the repository at this point in the history
- Searching for a GenericEvent is very slow, this should avoid doing a full
table scan each time
  • Loading branch information
tobyprivett committed Nov 26, 2024
1 parent f409cc0 commit f33e6af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions db/migrate/20241125114943_add_index_to_generic_events_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddIndexToGenericEventsType < ActiveRecord::Migration[8.0]
def change
add_index :generic_events, :type
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.0].define(version: 2024_11_18_095830) do
ActiveRecord::Schema[8.0].define(version: 2024_11_25_114943) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_catalog.plpgsql"
Expand Down Expand Up @@ -284,6 +284,7 @@
t.index ["occurred_at"], name: "index_generic_events_on_occurred_at"
t.index ["recorded_at"], name: "index_generic_events_on_recorded_at"
t.index ["supplier_id"], name: "index_generic_events_on_supplier_id"
t.index ["type"], name: "index_generic_events_on_type"
t.index ["updated_at"], name: "index_generic_events_on_updated_at"
end

Expand Down

0 comments on commit f33e6af

Please sign in to comment.