一.ICP
注意一下ICP的使用条件:
二.order by .. ?limit ...优化
from mysql 5.6.2 开始对order by .. ?limit ...优化:
select col1,col2 from tx order by no_key_col limit offset,rowcount;
From 5.6.2 by treating the sort buffer as a priority queue:
Before 5.6.2,Previously, the server performed this operation by using a merge file for the sort:
The cost of the table scan is the same for the queue and merge-file methods, so the optimizer chooses between methods based on other costs:
算法:
5.6使用queue:
把select 的列放入队列里,当队列满了把队列最后的出队列,就是把最大的、次大的、.....依次推到队列的前面,表所有行的列全部放完后,把第一个前rowcount 出队列,依次进行,都在sort buffer?里排序。
5.6之前:使用 merge file
把row insert 到 sort buffer,sort buffer相当于一个堆栈,sort buffer被插满了,依次把当前堆栈里前面的rowcount出队列放入到merge file,直到所有的排好序,然后通过merge file?再排序取出结果。
--------------------------------------分割线 --------------------------------------
--------------------------------------分割线 --------------------------------------