当前位置:Gxlcms > 数据库问题 > Mysql SQL 优化案例1

Mysql SQL 优化案例1

时间:2021-07-01 10:21:17 帮助过:18人阅读

AI_AD_U_L_TEMP` AS a WHERE a.`ca_id`=t.`ca_id`);

 

第一步:

查看表上的索引: show index from  AI_AD_U_L; show index from I_AD_U_L_TEMP

 发现关联字段上a.ca_id 上没有索引

第二步:

在表a 上创建索引

alter table `AI_AD_U_L_TEMP` add index idx_ca_id(ca_id);

 

第三步:

开启profiling:

show variables like ‘%pro%‘;

set profiling=1;

第四步:

执行SQL;

 耗时98秒。

第五步:

 查看执行时长:

show profiles;

show profile for query N;

 没有哪一步消耗时间特别长。

set profiling=0;

 

 

粗略记录,以备忘。

Mysql SQL 优化案例1

标签:除了   中断   sql语句   display   mysql sql   span   form   float   add   

人气教程排行