| 隐藏 | db.coll.hideIndex("status_ts") |
|---|---|
| 恢复 | db.coll.unhideIndex("status_ts") |
| 限制 | _id 索引不可隐藏 |
示例
示例
db.orders.hideIndex("status_ts")
db.orders.find({ status: "paid" }).explain("executionStats")隐藏期间索引仍随写入维护,只影响查询选择;确认无副作用后再真正 dropIndex。
hideIndex 让索引对查询规划器不可见:可以在不删索引的前提下验证“移除它会影响哪些查询”,随时可恢复。
| 隐藏 | db.coll.hideIndex("status_ts") |
|---|---|
| 恢复 | db.coll.unhideIndex("status_ts") |
| 限制 | _id 索引不可隐藏 |
db.orders.hideIndex("status_ts")
db.orders.find({ status: "paid" }).explain("executionStats")