Mysql实例在大数据情况下MySQL的一种简单分页优化方法
《Mysql实例在大数据情况下MySQL的一种简单分页优化方法》要点: 通常应用需要对表中的数据进行翻页,如果数据量很大,往往会带来性能上的问题: root@sns 07:16:25>select count(*) from reply_0004 where thread_id = 5616385 and deleted = 0; +―――-+ | count(*) | +―――-+ | 1236795 | +―――-+ 1 row in set (0.44 sec) root@sns 07:16:30>select id from reply_0004 where thread_id = 5616385 and deleted = 0 order by id asc limit 1236785,10 ; +―――C+ | id | +―――C+ | 162436798 | | 162438180 | | 162440102 | | 162442044 | | 162479222 | | 162479598 | | 162514705 | | 162832588 | | 162863394 | | 162899685 | +―――C+ 10 rows in set (1.32 sec) 索引:threa_id+deleted+id(gmt_Create) root@snsgroup 07:16:49>select * from (select id -> from group_thread_reply_0004 where thread_id = 5616385 and deleted = 0 -> order by id desc limit 0,10)t order by t.id asc; +―――C+ | id | +―――C+ | 162436798 | | 162438180 | | 162440102 | | 162442044 | | 162479222 | | 162479598 | | 162514705 | | 162832588 | | 162863394 | | 162899685 | +―――C+ 10 rows in set (0.87 sec) 可以看到性能提升了50%以上. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |