背景:
库里面有张表,日增数据量百万条;
之前查询:
SELECT * FROM `res_battery_data_history` LIMIT 1797000,10;
优化方法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
优化方法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
感觉还可以;