select ot.otid,ob.objname,ot.parenttype,ot.systypeid,ob.oid,ob.systemid,ot.list,ot.logictype  from objecttype ot,objects ob  where ot.list='0' and ot.otid=ob.otid and ob.systemid in(select  systemid from systypegroup sg, systemtype st ,systems ss where st.systypegrpid=sg.systypegrpid and sg.systypegrpid='2' and ss.systypeid=st.systypeid) order by ot.otid
用这种方法查询数据内容.感觉比较慢.想问下,有没有好的方法优化一下?

解决方案 »

  1.   

    select ot.otid,ob.objname,ot.parenttype,ot.systypeid,ob.oid,ob.systemid,ot.list,ot.logictype  
    from objecttype ot   
     join objects ob  on  ot.otid=ob.otid
     join     (select  systemid from systypegroup sg, systemtype st ,systems ss where st.systypegrpid=sg.systypegrpid and sg.systypegrpid='2' and ss.systypeid=st.systypeid)  cs  on ob.systemid=cs.systemid
    where  ot.list='0'
    order by ot.otid 
      

  2.   

    用一个函数实现吧,与mssql中的存储过程类似,可以在数据库内部自动分析并自动优化