How can mysql or mongodb, build an index for multi-conditional retrieval?

clipboard.png

in this diagram, it is a composite retrieval of multiple conditions, and the crux of the problem is that any condition in it can be combined at will. It may be three conditions, it may be five conditions, and the possible three conditions may be different, it may be the order status as the beginning of the three conditions, or the order source as the beginning of the five conditions.

both mongodb and msyql, composite indexes must have a primary field, which cannot be used by the query if it does not use the primary field. Then such random conditions are combined in a random number in a random order, how to build an index, how many indexes have to be established if all are to be covered, and if the new conditions are extended later, there is no way to expand.

in the face of so many conditional searches, how can the mysql or mongodb, you are familiar with build such an index?

Oct.06,2021
Menu