我做在mysql命令行此查询(不通过任何类型的代码)我InnoDB表返回0的COUNT(*)
select count(*) from books where
publisher_id = 46 AND deleted = 0 AND status_id = 3;
返回0(有时),但除去计数,它有很多结果。
这可能是什么原因造成的?我扔在命令行此查询(不通过任何一种编程层)
解释数查询得到:
Using intersect(IDX_cms_books_publisher_id,IDX_cms_books_status_id,IDX_cms_books_deleted); Using where; Using index
'返回0(有时),但删除计数,它有很多结果。'什么'有时'的意思是? – Pred
444,282205220 ........(它太大了,这里是查询,如果你怀疑) select * from books where publisher_id = 46 AND deleted = 0 AND status_id = 3 LIMIT 1 –
https ://www.percona.com/blog/2012/12/14/the-optimization-that-often-isnt-index-merge-intersection/+ – DanFromGermany