9 lines
450 B
Plaintext
9 lines
450 B
Plaintext
|
use digimon_product;
|
||
|
|
||
|
# 精確查詢與範圍條件組合索引
|
||
|
db.product_item.createIndex({"reference_id": 1}) # 精確匹配 reference_id
|
||
|
db.product_item.createIndex({"sale_start_time": 1, "sale_end_time": 1}) # 範圍查詢索引,提升 SaleStartTime 與 SaleEndTime 查詢效率
|
||
|
db.product_item.createIndex({"status": 1}) # 精確查詢 status
|
||
|
|
||
|
# 排序索引
|
||
|
db.product_item.createIndex({"created_at": -1}) # 用於按 created_at 倒序排序
|