Get the App
SLTechnology News&Howtos  ›  Database  › 

Handwriting-- mongo index building

Shulou Source: shulou.com Published: 2022-06-01 02:31:20 10月04日 Update

Remember: database operation should be cautious, it is recommended to do a good job in the operation of failed operations, but also in a timely manner.

Because of the index established this time, the background creates it, and finds corresponding measures, such as: the creation of the index can be interrupted in time.

Index creation operation: the following operations have been done in tables with tens of millions of data

1. Check whether the collection has an index: db.getCollection ("_ TEMPLATE_TASK_TIME_HISTORY") .getIndexes () 2. Total index size: db.getCollection ("_ TEMPLATE_TASK_TIME_HISTORY") .totalIndexSize () 3. Delete index (execute in the background if you can): db.getCollection ("_ TEMPLATE_TASK_TIME_HISTORY"). DropIndex ({"countTime": 1}, {background:true}) 4, create the index (be sure to execute in the background, otherwise lock the library The reason is that a large number of reads and writes will mess up the data during indexing): db.getCollection ("_ TEMPLATE_TASK_TIME_HISTORY"). DropIndex ({"countTime": 1}, {background:true}) 5. Check the progress of index creation: db.currentOp (). Inprog.forEach (function (op) {if (op.msg) print (op.msg)}) how to interrupt the progress of the index being created: https://cloud.tencent.com/developer/article/1502344

Tags: Index background data progress ten thousand items reason size suggestion total value measure database is in in table thousands hours processing practice handwriting Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Microsoft Linux NVidia MariaDB