Mongodb: when to call ensureIndex?

后端 未结 7 942
囚心锁ツ
囚心锁ツ 2021-02-01 01:34

When should I call ensureIndex? Before inserting a single record, after inserting a single record, or before calling find()?

Regards,

Johnny

相关标签:
7条回答
  • 2021-02-01 02:31

    If you add an index before hand, every insert/update/delete call has to modify each index also. So, from an optimization stand point, you probably want to put it off as long as possible before issuing queries. However, from a functional stand point, it doesn't matter.

    0 讨论(0)
提交回复
热议问题