关于spPager的建议

#1 wltony

由于数据表内有几百万条数据,而SP分页程序 spModel.php 436行使用
SELECT COUNT({$this->model_obj->pk}) 后面如果有where 条件
如sql语句 select count(id) from table where letter='a';
使用了select count(id) 使得Mysql的占用cpu很高,建议修改成select count(*) 比较合适,或者直接传递参数进去也可以,不要都使用主键;当然findCount也是一样问题;

该贴已经同步到 wltony的微博

2011-12-31 14:40:13

#2 jake

是的,你说的对,我才发现,原来count(*)比count(id)效率要高。

看这文章知道的:http://www.ccvita.com/156.html

2012-01-01 09:53:43