mirror of
https://github.com/discourse/discourse.git
synced 2025-10-03 17:21:20 +08:00
PERF: correctly index event dates (#34877)
This commit is contained in:
parent
587a180a66
commit
f6e71b463c
3 changed files with 14 additions and 1 deletions
|
@ -69,6 +69,7 @@ end
|
|||
# Indexes
|
||||
#
|
||||
# idx_discourse_calendar_post_event_dates_event_id_starts_at_uniq (event_id,starts_at) UNIQUE
|
||||
# index_discourse_calendar_post_event_dates_on_event_id_and_dates (event_id,finished_at DESC,starts_at DESC)
|
||||
# index_discourse_calendar_post_event_dates_on_event_id (event_id)
|
||||
# index_discourse_calendar_post_event_dates_on_finished_at (finished_at)
|
||||
#
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddDistinctOnOptimizationIndexToEventDates < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_index :discourse_calendar_post_event_dates,
|
||||
%i[event_id finished_at starts_at],
|
||||
name: "index_discourse_calendar_post_event_dates_on_event_id_and_dates",
|
||||
order: {
|
||||
finished_at: :desc,
|
||||
starts_at: :desc,
|
||||
}
|
||||
end
|
||||
end
|
|
@ -23,7 +23,6 @@ module DiscoursePostEvent
|
|||
DiscoursePostEvent::Event
|
||||
.visible
|
||||
.open
|
||||
.includes(:event_dates, :post, post: :topic)
|
||||
.joins(post: :topic)
|
||||
.merge(Post.secured(guardian))
|
||||
.merge(topics.or(pms))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue