mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 05:06:51 +08:00
- Add indexes in some places where we were seeing bottlenecks - Remove redundant ILIKE query --------- Co-authored-by: Gerhard Schlager <gerhard.schlager@discourse.org>
33 lines
863 B
Ruby
33 lines
863 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AddUserIndexToIncomingLinks < ActiveRecord::Migration[7.2]
|
|
disable_ddl_transaction!
|
|
|
|
def up
|
|
execute <<~SQL
|
|
DROP INDEX CONCURRENTLY IF EXISTS index_incoming_links_on_user_id
|
|
SQL
|
|
|
|
execute <<~SQL
|
|
CREATE INDEX CONCURRENTLY index_incoming_links_on_user_id ON incoming_links(user_id) WHERE user_id IS NOT NULL
|
|
SQL
|
|
|
|
execute <<~SQL
|
|
DROP INDEX CONCURRENTLY IF EXISTS index_incoming_links_on_current_user_id
|
|
SQL
|
|
|
|
execute <<~SQL
|
|
CREATE INDEX CONCURRENTLY index_incoming_links_on_current_user_id ON incoming_links(current_user_id) WHERE current_user_id IS NOT NULL
|
|
SQL
|
|
end
|
|
|
|
def down
|
|
execute <<~SQL
|
|
DROP INDEX IF EXISTS index_incoming_links_on_user_id
|
|
SQL
|
|
|
|
execute <<~SQL
|
|
DROP INDEX IF EXISTS index_incoming_links_on_current_user_id
|
|
SQL
|
|
end
|
|
end
|