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
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-1b3ae41-2c253.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-1b3ae41-2c253.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?