Skip to content

Commit

Permalink
CV2-5138: add more index to improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Sep 24, 2024
1 parent 01628ef commit ce1980f
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 140 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class AddIndexToCreatedAtForTiplineRequest < ActiveRecord::Migration[6.1]
def change
execute "CREATE INDEX tipline_request_created_at_year ON tipline_requests (date_trunc('year', created_at))"
execute "CREATE INDEX tipline_request_created_at_quarter ON tipline_requests (date_trunc('quarter', created_at))"
execute "CREATE INDEX tipline_request_created_at_month ON tipline_requests (date_trunc('month', created_at))"
execute "CREATE INDEX tipline_request_created_at_week ON tipline_requests (date_trunc('week', created_at))"
execute "CREATE INDEX tipline_request_created_at_day ON tipline_requests (date_trunc('day', created_at))"
add_index :tipline_requests, :created_at
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class AddIndexToCreatedAtForTiplineMessage < ActiveRecord::Migration[6.1]
def change
execute "CREATE INDEX tipline_message_created_at_year ON tipline_messages (date_trunc('year', created_at))"
execute "CREATE INDEX tipline_message_created_at_quarter ON tipline_messages (date_trunc('quarter', created_at))"
execute "CREATE INDEX tipline_message_created_at_month ON tipline_messages (date_trunc('month', created_at))"
execute "CREATE INDEX tipline_message_created_at_week ON tipline_messages (date_trunc('week', created_at))"
execute "CREATE INDEX tipline_message_created_at_day ON tipline_messages (date_trunc('day', created_at))"
add_index :tipline_messages, :created_at
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddCreatedAtIndexForDataPoints < ActiveRecord::Migration[6.1]
def change
add_index :tipline_subscriptions, :created_at
add_index :tipline_newsletter_deliveries, :created_at
add_index :annotations, :created_at
end
end
Loading

0 comments on commit ce1980f

Please sign in to comment.