佳音的博客 方乃做人之本,圆乃处世之道

2008/11/28

ORDER BY Optimization

Filed under: Uncategorized — 佳音 @ 4:57 下午
http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html


SELECT * FROM t1
ORDER BY key_part1,key_part2,... ;

SELECT * FROM t1
WHERE key_part1=constant
ORDER BY key_part2;

SELECT * FROM t1
ORDER BY key_part1 DESC, key_part2 DESC;

SELECT * FROM t1
WHERE key_part1=1
ORDER BY key_part1 DESC, key_part2 DESC;

Powered by WordPress