mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 04:31:56 +08:00
fe5cd479eb
Why this change? In `PostDestroyer#make_previous_post_the_last_one` and `Topic.reset_highest`, we have a query that looks something like this: ``` SELECT user_id FROM posts WHERE topic_id = :topic_id AND deleted_at IS NULL AND post_type <> 4 #{post_type} ORDER BY created_at desc LIMIT 1 ``` However, we currently don't have an index that caters directly to this query. As a result, we have seen this query performing poorly on large sites if the PG planner ends up using an index that is suboptimal for the query. This commit adds an index to the `posts` table on `topic_id` and then `created_at`. For the query above, PG will be able to do a backwards index scan efficiently. |
||
---|---|---|
.. | ||
fixtures | ||
migrate | ||
post_migrate | ||
api_test_seeds.rb |