凌的博客

您现在的位置是: 首页 > 学无止境 > mysql > 

mysql

mysql语句limit优化

2016-05-16 mysql 1029
mysql都说性能比不上 sql 、oracle 确实,mysql在百万级内的数据还可以,当到了千万,亿级就玩不动了。 这里特别指出mysql limit 语句: 比如 select id from table where vtype=1 limit 1000,10;

mysql都说性能比不上 sql 、oracle 确实,mysql在百万级内的数据还可以,当到了千万,亿级就玩不动了。


这里特别指出mysql limit 语句:

比如

select id from table where vtype=1 limit 1000,10;

select id from table where vtype=1 limit 100000,10;

这样都很快

但是:


select id,title from table where vtype=1 limit 100000,10; //会很慢,因为已经不按索引来查了

那么 如果

select id from table where vtype=1 limit 100000,10; //先查出来id

然后:

select id,title from table where vtype=1 and id in(3,3,54,6);

这样会很快! 就现在看这个是个完美解决的方式。




文章评论

0条评论