博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

查询优化

Posted on 2010-05-07 18:01  Learn more  阅读(113)  评论(0编辑  收藏  举报

尽量先过滤数据再进行表连接,

例如:select a from tblUser inner join tblShop on tblUser.id=tblShop.id

              inner join tblThing on tblUser.id=tblThing.id

   where tblUser.id=4

 

改为 select a

   from (select * from tbluser where tbluser.id=4) as tblUser

      inner join tblShop on tblUser.id=tblShop.id

  inner join tblThing on tblUser.id=tblThing.id

 

 

 

MSDN:http://172.18.14.131/LockSmith/Default.aspx

Great site