Doubts about mongoose autoIndex

When the official document on

mongoose says that the autoIndex property is true, when the application starts, mongoose will automatically call ensureIndex for your schema to ensure that the index is generated. It is good to use this in the development environment, but it is not recommended in the production environment. In that case, how to build the index, do you have to manually use mongo shell to build the index one by one?

Mar.20,2021

creating an index is an one-time task, and manual creation is the best choice in mongo shell. Why do you say "isn't it"?
this is not just a question of how many times it will be executed, when it will be executed, and whether it will affect the production environment. To understand that the indexing process is a great consumption to the database, the foreground index locks all CRUD operations on the entire collection, while the background index is not locked directly, but it still consumes a lot of CPU and IO to read the document and modify the index. Either way, it is possible to consume a lot of time and resources (such as creating an index on a larger collection). This is also the reason why mongoose is not recommended for use in production environments.
production environment requires stability, convenience is secondary. When it comes to "stability", it is bound to be "convenience" to make concessions.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea7fdd-1ea2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea7fdd-1ea2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?