Home > database >  Mysql order table index how to create, you can create multiple composite index?
Mysql order table index how to create, you can create multiple composite index?

Time:09-22

Recently looked at, the optimized plan for the database are still a little confused,, every brother please advice, thanks!
For example the order table
Order_id order id
Order_sn order no.
User_id user ID
Supplier_id merchant ID
Order_status order status
Pay_status pay state
Ship_status delivery status

Temporary lists the main fields

Create indexes problem:
1, the user can see the order list, according to user's ID_ order status pay _ _ the delivery state to create a composite index
2, the merchants can see the order list according to the businessman ID_ order status pay _ _ the delivery state to create a composite index

If there are other case, if they were going to continue to create various composite index (for example: the company background about statistical check all order list, etc.)?
The great god, please give directions, thank you

CodePudding user response:

Index is established on the basis of the use of,
Which field the query will be used, at least use frequency, to build the index, if it is a composite index, using high frequency field on the front,
Using the same frequency fields, difference big field, on the front,

CodePudding user response:

As the upstairs said, don't indexed for indexed, if the data is not very big (more than 500000), does not need to be indexed, today's disk read/write speed is not slow,
The original poster can refer to the following article
https://www.cnblogs.com/Aiapple/p/5693239.html

CodePudding user response:

reference 1st floor AHUA1001 response:
index is established on the basis of the use,
Which field the query will be used, at least use frequency, to build the index, if it is a composite index, using high frequency field on the front,
Using the same frequency fields, difference big field, on the front,


Like I said the problem, the user sees the list of orders, to build a set of consistent with the index, businessman that a list of orders, to build a set of composite index, this make sense? (here is only a normal list under each state, did not involve search)

CodePudding user response:

There should be no problem, the index to build several sets of furniture, how to build, is created according to the query conditions,
Usually one table, two or three index is normal, and special, and not more than five,
Index is too much, will affect the rate of add deletion,
You said the search, what refers to,
  • Related