discourse/db
Martin Brennan c452e4275f
FIX: Add extra tag_id, topic_id index to topic_tags (#35565)
In some pathological cases on the tag intersection route
for topics, when querying across multiple tags, the SQL query
planner can choose a suboptimal plan that results in a
sequential scan of the topic_tags table instead of using
the existing topic_id, tag_id index.

```
->  Parallel Seq Scan on topic_tags t2  (cost=0.00..23043.22 rows=13618 width=4) (actual time=0.031..54.114 rows=10535 loops=3)
                                                                     Filter: (tag_id = 58)
                                                                     Rows Removed by Filter: 579415
```

This resulted in a very slow query. Adding this extra
index allows us to hint the query planner to use a more
efficient plan by filtering using the tag ID first _then_ the topic ID.
2025-10-23 17:34:16 +10:00
..
fixtures FIX: Allow creating new color palettes based on custom palettes (#34351) 2025-08-20 11:58:40 +08:00
migrate FIX: Add extra tag_id, topic_id index to topic_tags (#35565) 2025-10-23 17:34:16 +10:00
post_migrate DEV: Remove dual mode support for palettes and drop theme-owned palettes (#34467) 2025-08-26 06:24:11 +03:00
api_test_seeds.rb DEV: Apply syntax_tree formatting to db/* 2023-01-09 11:59:41 +00:00