下面那种语句执行效率高?! ( 积分: 50 )

  • 主题发起人 主题发起人 nciwp
  • 开始时间 开始时间
N

nciwp

Unregistered / Unconfirmed
GUEST, unregistred user!
第一种:<br>select&nbsp;*&nbsp;from&nbsp;HT_SUSPINFO&nbsp;&nbsp;a,<br>(<br>SELECT&nbsp;XLH&nbsp;FROM&nbsp;<br>(<br>SELECT&nbsp;ROWNUM&nbsp;RN&nbsp;,A.XLH<br>FROM&nbsp;<br>(<br>select&nbsp;xlh&nbsp;&nbsp;from&nbsp;(<br>(select&nbsp;XLH,bksj&nbsp;from&nbsp;HT_SUSPINFO&nbsp;&nbsp;&nbsp;t&nbsp;<br>&nbsp;where&nbsp;bksj&gt;(sysdate&nbsp;-10&nbsp;)<br>&nbsp;and&nbsp;HPHM&nbsp;like&nbsp;'浙%'<br>&nbsp;order&nbsp;by&nbsp;bksj&nbsp;desc)&nbsp;A&nbsp;<br>)<br>WHERE&nbsp;RN&nbsp;&gt;=&nbsp;0&nbsp;and&nbsp;RN&lt;=500<br>)&nbsp;b&nbsp;<br>where&nbsp;a.XLH&nbsp;=b.xlh&nbsp;<br><br>第二种:<br>select&nbsp;*&nbsp;from&nbsp;HT_SUSPINFO&nbsp;&nbsp;a,<br>(<br>SELECT&nbsp;XLH&nbsp;FROM&nbsp;<br>(<br>SELECT&nbsp;ROWNUM&nbsp;RN&nbsp;,c.XLH<br>FROM&nbsp;(select&nbsp;xlh,hphm&nbsp;from(select&nbsp;XLH,hphm&nbsp;from&nbsp;HT_SUSPINFO&nbsp;&nbsp;&nbsp;t&nbsp;<br>&nbsp;where&nbsp;bksj&gt;(sysdate&nbsp;-10&nbsp;)<br>&nbsp;order&nbsp;by&nbsp;bksj&nbsp;desc)&nbsp;A)&nbsp;c<br>&nbsp;where&nbsp;c.hphm&nbsp;like&nbsp;'浙%'<br>&nbsp;)<br>WHERE&nbsp;RN&nbsp;&gt;=&nbsp;0&nbsp;and&nbsp;RN&lt;=500<br>)&nbsp;b&nbsp;<br>where&nbsp;a.XLH&nbsp;=b.xlh&nbsp;<br><br>第一种两个条件&nbsp;第二种先过虑&nbsp;在查询条件二<br><br>数据库oracle9&nbsp;数据:170w++&nbsp;,我测试情况&nbsp;第二种比第一种快很多,第一种查询很久没有结果,受不了就停下它了,第二种&nbsp;大概0.04s左右,以前一直认为第一种快,请高手解答下!谢谢
 
后退
顶部