简体   繁体   中英

How to optimize big table in MySQL

我有一个带有2列的表,其中一个是唯一的...在此表中,我有112000万行...选择和删除单行的查询需要60秒钟以上...这是正常现象吗?减少执行时间?

Post your DDL.

Typically you want to make sure you have appropriate indexing.

Review your execution plan.

The size of table should be irrelevant for single row deletes with an appropriate choice of index.

There might be many reasons, we need for information:

  1. Types of the columns - are they varchar, text, int ?
  2. Query you try to invoke
  3. use EXPLAIN Query and copy paste the result
  4. Do you have any indexes ?

Most probably you do not have proper indexes. If you do have them, it might be the case that they are not used. For example, if you have id, varchar and you try to do select * from table where varchar LIKE '%something%' then your index on varchar column cannot be used. That is why we need result of explain.

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