天天看点

MySQL 语句优化

select * from b_common_product_param where cname = 'Type' order by ename limit 100000, 10;

select * from b_common_product_param INNER JOIN 

(select id from b_common_product_param where cname = 'Type' order by ename limit 100000, 10) as x using (id);

#第一条Sql查询时间:49.612

#第二条Sql查询时间:22.545

表数据:12740129

用于表连接时给定连接条件(可以理解为简写形式),如

SELECT * FROM table1     JOIN table2 ON table1.id = table2.id 

使用 USING 可以写为:

SELECT * FROM table1   JOIN table2 USING(id)

本文转自 a928154159 51CTO博客,原文链接:http://blog.51cto.com/zhibeiwang/1787656