Home > Database > Mysql Tutorial > MySql 查询优化小结(一)

MySql 查询优化小结(一)

WBOY
Release: 2016-06-07 16:15:50
Original
1100 people have browsed it

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
Copy after login

?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
Copy after login

?10W 条数据,查询时间大约 ?0.17s

?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template