MongoDB’s index needs to consider the index direction of each key. Why is it designed like this? MySQL’s index does not need to consider the direction. What are the advantages and disadvantages of the two?

  mysql, question

To create an index for a table/collection:

//Create an index for the collection. The following will create two different indexes
 db.col.ensureIndex({user_id:-1, status:-1})
 db.col.ensureIndex({user_id:1, status:1})
 //Create Index for Table
 alter table table_name add index idx_name(`user_id`, `status`)

Mongodb and mysql have different index implementations. Mongodb is not very familiar with it. So only for mysql:

Mysql implements indexes in btree or btree variants with the same preamble and Postorder Traversal.

At the same time mysql’s index also supports ascending and descending order, but the default is ascending order.