select count(*) TotleCount from 
 Article a  
 join ContainerFunc cf on a.ArticleKey = cf.ContainerKey  
 where a.InfoSetKey in  (SELECT  g.infosetkey FROM Infoset g
  CONNECT BY prior  g.infosetkey =  g.parentkey    
  START WITH g.infosetkey =12858) and cf.Status = 2不知道这样的sql语句怎么优化?

解决方案 »

  1.   

    select count(*) TotleCount from 
     Article a,ContainerFunc cf,(SELECT  g.infosetkey FROM Infoset g
      CONNECT BY prior  g.infosetkey =  g.parentkey    
      START WITH g.infosetkey =12858) b where a.ArticleKey = cf.ContainerKey  
     and a.InfoSetKey=b.InfoSetKey and cf.Status = 2
      

  2.   

    select count(*) TotleCount from 
     Article a,ContainerFunc cf
    where a.ArticleKey = cf.ContainerKey  
     and a.InfoSetKey=b.InfoSetKey and cf.Status = 2
    and exists(select 1 from Infoset g where g.infosetkey = a.infosetkey CONNECT BY prior  g.infosetkey =  g.parentkey  START WITH g.infosetkey =12858)