多表连接这个表该怎么优化

多表连接这个表该怎么优化

多表连接这个表该如何优化

这个sql这样写可以吗 (在线高并发环境)

select t.* from Ty t,User u, Ae a where u.pId = 7 and t.uId =a.uId and t.aId=a.id and t.ud= u.id and (t.type =2 or t.Type =3) order by t.id desc limit 20

在某些工具分析这个sql写得不是很好 的 , 请问该如何调整

( t(id, aid , uid ) u(id ,aid) a(id ,uid) )

User u 和 Ae a之间是1对多的关系 。 就是说一个user表不同的id 有不同的aid, 但是aid每条记录都有userid ,不同的ae 可以有相同的uid。

  Ty是交易表, 他跟User u, Ae a 2个都是1对多的关系. 

请问这个表该如何优化??



explain select ..

show index from …

贴出来看一下。




引用explain select ..

show index from …

贴出来看一下。



/zyz/




把t.Type的作为索引吧

多表连接这个表该怎么优化

相关文章:

你感兴趣的文章:

标签云: