2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-03 23:54:20 +08:00
discourse/db/migrate/20260112032646_drop_unused_top_topics_count_indexes.rb
Alan Guo Xiang Tan 24d4fc4825
PERF: Drop unused indexes on top_topics table (#37053)
The top_topics table had 20 indexes on count columns (daily_posts_count,
daily_views_count, etc.) that were never used according to
pg_stat_user_indexes. Only the *_score indexes are queried for /top
pages.
2026-01-12 12:55:28 +08:00

30 lines
1.2 KiB
Ruby

# frozen_string_literal: true
class DropUnusedTopTopicsCountIndexes < ActiveRecord::Migration[8.0]
def up
remove_index :top_topics, :daily_posts_count
remove_index :top_topics, :daily_views_count
remove_index :top_topics, :daily_likes_count
remove_index :top_topics, :daily_op_likes_count
remove_index :top_topics, :weekly_posts_count
remove_index :top_topics, :weekly_views_count
remove_index :top_topics, :weekly_likes_count
remove_index :top_topics, :weekly_op_likes_count
remove_index :top_topics, :monthly_posts_count
remove_index :top_topics, :monthly_views_count
remove_index :top_topics, :monthly_likes_count
remove_index :top_topics, :monthly_op_likes_count
remove_index :top_topics, :quarterly_posts_count
remove_index :top_topics, :quarterly_views_count
remove_index :top_topics, :quarterly_likes_count
remove_index :top_topics, :quarterly_op_likes_count
remove_index :top_topics, :yearly_posts_count
remove_index :top_topics, :yearly_views_count
remove_index :top_topics, :yearly_likes_count
remove_index :top_topics, :yearly_op_likes_count
end
def down
raise ActiveRecord::IrreversibleMigration
end
end