I want to create table for store customer and daily statistic.
customer_stat table - (PK)on_date - (PK)customer_id - (PK)margin_id - (PK)agent_id
Search scenarios: - search by compound all primary keys - search by customer_id - search by margin_id - search by agent_id + margin_id
From scenarios above, should I create separate index for each key column or mysql already auto create index of each key for me?
I found solution to test this concept. I create table follow above structure with compound key, then test insert to database. Then check table structure in database, and found that:
MySQL create single index for compound primary key.
So I need to manual create separate index of each column for used in query by partial of key in compound keys.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.