Adding MongoDB indexes can reduce query time and RAM usage.

This commit is contained in:
chiu 2025-12-11 06:15:06 +00:00
parent 4982b34a03
commit f280f1e5ec
1 changed files with 3 additions and 0 deletions

View File

@ -123,6 +123,9 @@ class Bulletin
index({postdate: 1}, { unique: false, background: true })
index({is_top: -1,postdate: -1, _id: -1}, { unique: false, background: true })
index({approved: -1,is_hidden: 1,is_preview: 1, is_top: -1,postdate: -1,_id: -1,deadline: -1}, { unique: false, background: true })
index({approved: -1,is_hidden: 1,is_preview: 1,category_id: 1,"title.zh_tw": 1,postdate: -1,deadline: 1}, {background: true,name: "idx_slow_query_zh_tw" })
index({approved: -1,is_hidden: 1,is_preview: 1,category_id: 1,"title.zh_cn": 1,postdate: -1,deadline: 1}, {background: true,name: "idx_slow_query_zh_cn" })
index({approved: -1,is_hidden: 1,is_preview: 1,category_id: 1,"title.en": 1,postdate: -1,deadline: 1}, {background: true,name: "idx_slow_query_en" })
if AnnouncementSetting.pluck(:enable_manually_sort).first == true
index({approved: -1,is_hidden: 1,is_preview: 1, is_top: -1,sort_number: 1,postdate: -1,_id: -1,deadline: -1}, { unique: false, background: true })
end