简体   繁体   English

mysql全表扫描

[英]full table scan in mysql

select *from REPT_AIR_PRY_HY1 RAP where (RAP.DATE_OF_ISSUE) BETWEEN "2017-10-01" AND DATE_ADD("2017-10-31", INTERVAL 1 DAY)

the explain plan of this query gives me 337243 but data s between these dates is only 55209 and there is even index is created on column DATE_OF_ISSUE .这个查询的解释计划给了我337243但这些日期之间的数据只有55209并且甚至在列 DATE_OF_ISSUE 上创建了索引。 So, why it is scanning the whole table?那么,为什么要扫描整个表呢? thanks in advance提前致谢

Some possibilities:一些可能性:

  • The optimizer thinks (correctly or incorrectly) that a non-trivial percentage of the table would be needed.优化器认为(正确或错误地)需要表的非平凡百分比。 How many rows in the table?表中有多少行?
  • You are using MyISAM;您正在使用 MyISAM; switch to InnoDB.切换到 InnoDB。
  • For some reason, the 'statistics' are stale.出于某种原因,“统计数据”已经过时。 Do ANALYZE TABLE .ANALYZE TABLE

To discuss further, please provide SHOW CREATE TABLE .要进一步讨论,请提供SHOW CREATE TABLE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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