FROM (
SELECT `p`.`Id`
FROM `putin_record` AS `p`
WHERE (`p`.`CustomerId` = 1) AND (`p`.`PutInNum` > `p`.`PutOutNum`)
ORDER BY `p`.`Id`
LIMIT 1 OFFSET 840000
) AS `t`
ORDER BY `t`.`Id`
LIMIT 1
建议优化:
SELECT `p`.`Id`
FROM `putin_record` AS `p` force index(idx_PutInNum_PutOutNum_CustomerId_id)
WHERE (`p`.`CustomerId` = 1) AND (`p`.`PutInNum` > `p`.`PutOutNum`)
ORDER BY `p`.`Id`
LIMIT 1 OFFSET 840000;
导出excel 此处,代码优化前:
优化后