简体   繁体   中英

mysql innodb indexing confused

I am building a mysql table: ID (auto int), cc char(9), tt int(11), mm char(3)

Now I have set the ID to be the primary index.

Every query will be either select or update with WHERE id='numberhere' LIMIT 1. (so its just 1 row at a timw ever needed)

Now, To get the correct performance benifit from using innodb, do I just leave ID as primary and only index in the table? or should I set everything as an index? I am unsure...

EDIT: no joins in the table, it is literally SELECT * FROM table WHERE id='2341...' everytime or same but with update...

You might set everything you join on as an index. Maybe even everything you use in a where . Too many indexes slow insertions/updates, as you have to create them, so it's down to use.

正如Nanne回答的那样,如果您始终在处理特定键,则将该列作为其自己的索引就很好了,并且在进行采样时,始终将该表作为SQL-Select语句中的第一个表以及WHERE子句中的第一个条件...如果您要对另一个表进行JOIN操作,请确保OTHER表在要匹配的列上具有索引,以优化该连接部分...

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM