mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: add a filtered index for banners
This ensures we can very quickly figure out which topics are banners if a banner is set. Previously you would have to scan an entire table to find banners
This commit is contained in:
7
db/migrate/20191101001705_add_banner_index_to_topics.rb
Normal file
7
db/migrate/20191101001705_add_banner_index_to_topics.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
class AddBannerIndexToTopics < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
# this speeds up the process for finding banners on the site
|
||||
add_index :topics, [:id], name: 'index_topics_on_id_filtered_banner', where: "archetype = 'banner' AND deleted_at IS NULL", unique: true
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user