Mysql优化分页

背景:

库里面有张表,日增数据量百万条;

之前查询:

SELECT
	*
FROM
	`res_battery_data_history`
LIMIT 1797000,10;

Mysql优化分页

优化方法1:

/*SELECT * FROM `res_battery_data_history` limit 1797000,10;*/
SELECT
	*
FROM
	res_battery_data_history
WHERE
	id >= (
		SELECT
			id
		FROM
			res_battery_data_history
		LIMIT 1797000,
		1
	)
LIMIT 10

Mysql优化分页

优化方法2:

SELECT
	*
FROM
	res_battery_data_history battery
JOIN (
	SELECT
		id
	FROM
		res_battery_data_history
	LIMIT 1797000,
	10
) temp ON battery.id = temp.id

Mysql优化分页

感觉还可以;

上一篇:LVS-DR实现web调度模式


下一篇:RSD 直观介绍