1. 程式人生 > >mysql 優化limit寫法

mysql 優化limit寫法

-- 優化前,查詢10005條,摒棄10000條,留下5條
SELECT
	film_id,
	description 
FROM
	film 
ORDER BY
	title 
	LIMIT 10000, 5;
	
	
-- 優化優化後寫法,具體是如何起到優化效果的呢?
SELECT
	film.film_id,
	film.description 
FROM
	film
	INNER JOIN ( SELECT film_id FROM film ORDER BY title LIMIT 10000, 5 ) AS tmp USING ( film_id );