时间:2021-07-01 10:21:17 帮助过:52人阅读
MySql 查询优化总结(一) 1、大数据分页查询,varchar 等大字段懒加载 通常代码: SELECT aj.N_BH, aj.C_AM, aj.C_AHFROM t_aj AS ajORDER BY aj.D_LARQ DESCLIMIT 100,10 ?10W 条数据,查询时间大约 ?0.73s ? 优化后: select aj.C_AM, aj.C_AH, aj.N_BHFRO
MySql 查询优化总结(一)1、大数据分页查询,varchar 等大字段懒加载
通常代码:
SELECT aj.N_BH, aj.C_AM, aj.C_AH FROM t_aj AS aj ORDER BY aj.D_LARQ DESC LIMIT 100, 10
?10W 条数据,查询时间大约 ?0.73s
?
优化后:
select aj.C_AM, aj.C_AH, aj.N_BH FROM ( SELECT aj.N_BH, aj.D_LARQ FROM t_aj AS aj ORDER BY aj.D_LARQ DESC LIMIT 100, 10 ) T inner join t_aj aj on t.N_BH = aj.N_BH
?10W 条数据,查询时间大约 ?0.17s
?