📄 oracle sql性能优化系列 (三)1--acnow_net.htm
字号:
<DIV id=article>
<TABLE cellSpacing=0 cellPadding=0 width=540 border=0 style="TABLE-LAYOUT: fixed">
<TBODY>
<TR>
<TH class=f24><FONT color=#05006c>
<H1>ORACLE SQL性能优化系列 (三)</H1>
</FONT></TH>
</TR>
<TR>
<TD> <HR SIZE=1 bgcolor="#d9d9d9"> </TD>
</TR>
<TR>
<TD align=middle height=20>http://Tech.acnow.net 2005-4-29 <FONT color=#a20010>网络</FONT></TD>
</TR>
<TR>
<TD height=15></TD>
</TR>
<TR>
<TD class=l17><FONT class=f14 id=zoom><BR>9. 整合简单,无关联的<a href="/Html/DataBase/" target="_blank">数据库</a>访问<BR><BR> <BR><BR>如果你有几个简单的数据库查询语句,你可以把它们整合到一个查询中(即使它们之间没有关系)<BR><BR>例如:<BR><BR> <BR><BR>SELECT NAME <BR><BR>FROM EMP <BR><BR>WHERE EMP_NO = 1234;<BR><BR> <BR><BR>SELECT NAME <BR><BR>FROM DPT<BR><BR>WHERE DPT_NO = 10 ;<BR><BR> <BR><BR>SELECT NAME <BR><BR>FROM CAT<BR><BR>WHERE CAT_TYPE = ‘RD’;<BR><BR> <BR><BR>上面的3个查询可以被合并成一个:<BR><BR> <BR><BR>SELECT E.NAME , D.NAME , C.NAME<BR><BR>FROM CAT C , DPT D , EMP E,DUAL X<BR><BR>WHERE NVL(‘X’,X.DUMMY) = NVL(‘X’,E.ROWID(+))<BR><BR>AND NVL(‘X’,X.DUMMY) = NVL(‘X’,D.ROWID(+))<BR><BR>AND NVL(‘X’,X.DUMMY) = NVL(‘X’,C.ROWID(+))<BR><BR>AND E.EMP_NO(+) = 1234<BR><BR>AND D.DEPT_NO(+) = 10<BR><BR>AND C.CAT_TYPE(+) = ‘RD’;<BR><BR> <BR><BR>(译者按: 虽然采取这种方法,效率得到提高,但是程序的可读性大大降低,所以读者 还是要权衡之间的利弊)<BR><BR> <BR><BR>10. 删除重复记录<BR><BR>最高效的删除重复记录方法 ( 因为使用了ROWID)<BR><BR> <BR><BR>DELETE FROM EMP E<BR><BR>WHERE E.ROWID > (SELECT MIN(X.ROWID) <BR><BR> FROM EMP X<BR><BR> WHERE X.EMP_NO = E.EMP_NO);<BR><BR> <BR><BR>11. 用TRUNCATE替代DELETE<BR><BR>当删除表中的记录时,在通常情况下, 回滚段(rollback segments ) 用来存放可以被恢复的信息. 如果你没有COMMIT事务,ORACLE会将数据恢复到删除之前的状态(准确地说是<BR><BR>恢复到执行删除命令之前的状况)<BR><BR> <BR><BR>而当运用TRUNCATE时, 回滚段不再存放任何可被恢复的信息.当命令运行后,数据不能被恢复.因此很少的资源被调用,执行时间也会很短.<BR><BR> <BR><BR>(译者按: TRUNCATE只在删除全表适用,TRUNCATE是DDL不是DML)<BR><BR> <BR><BR> <BR><BR>12. 尽量多使用COMMIT<BR><BR> <BR><BR>只要有可能,在程序中尽量多使用COMMIT, 这样程序的性能得到提高,需求也会因为COMMIT所释放的资源而减少:<BR><BR> COMMIT所释放的资源:<BR><BR>a. 回滚段上用于恢复数据的信息.<BR><BR>b. 被程序语句获得的锁<BR><BR>c. redo log buffer 中的空间<BR><BR>d. ORACLE为管理上述3种资源中的内部花费<BR><BR> <BR><BR>(译者按: 在使用COMMIT时必须要注意到事务的完整性,现实中效率和事务完整性往往是鱼和熊掌不可得兼)<p><div align="right">本新闻共<font color=red>2</font>页,当前在第<font color=red>2</font>页 <a href="164558059816455894796.shtml">1</a> <font color="red">2</font> </div></p>
<P clear=all></P>
</FONT></TD>
</TR>
</TBODY>
</TABLE>
</DIV>
<BR>
上一篇:<a href='../../2005-4/29/164558059816455859548.shtml' title ='突破oracle for win2K的2G内存限制'>突破oracle for win2K的2G内存限制</a> 下一篇:<a href='../../2005-4/29/164558059816455889051.shtml' title ='在DB2中如何實現Oracle的相關功能(四)'>在DB2中如何實現Oracle的相關功能(四)</a>
<BR>
<BR>
<TABLE class="tf" cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD style="PADDING-RIGHT: 20px" align=right>
【<script type="text/javascript">
<!--
document.write("<a href=\"http:\/\/tech.acnow.net\/Sendmail.asp?NewsID=059816455894796\" target=\"_blank\">发送给好友</a>");
-->
</script>】
【<A href="http://bbs.acnow.net/Index.asp?boardid=103">论坛</A>】
【<script type="text/javascript">
<!--
document.write("<a target=\"_blank\" Href=\"http:\/\/tech.acnow.net\/Users\/AddFavorite.asp?NewsID=8960\" style=\"CURSOR:hand\" onClick=\"window.external.AddFavorite(document.location.href,document.title)\" onMouseMove=\"status='收藏本页';\" onMouseOut=\"status='';\">添加到收藏夹</a>");
-->
</script>】
【<A target="_self" href="javascript:doZoom(16)">大</A>
<A target="_self" href="javascript:doZoom(14)">中</A>
<A target="_self" href="javascript:doZoom(12)">小</A>】
【<A target="_self" href="javascript:doPrint()">打印</A>】
【<A target="_self" href="javascript:window.close()">关闭</A>】</TD>
</TR>
</TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=545 border=0>
<TBODY>
<TR>
<TD height=19></TD>
</TR>
<TR>
<TD bgColor=#c6c9d1 height=1></TD>
</TR>
<TR>
<TD height=10></TD>
</TR>
</TBODY>
</TABLE>
<BR>
<DIV id=links>
<TABLE cellSpacing=0 cellPadding=0 width=542 border=0>
<TBODY>
<TR>
<TD><table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td><img src="http://tech.acnow.net/Files/Img/list_nav_spacer.gif"><a Class="a2" href= http://tech.acnow.net/Html/DataBase/Oracle/2005-4/29/164559059816455960820.shtml title="ORACLE SQL性能优化系列 (十四) 完结篇">ORACLE SQL性能优化系列 (十四) 完结篇</a></td></tr>
<tr>
<td Height=1 colspan="1">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td Height=1 background="http://tech.acnow.net/Files/Img/title_line.gif">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><img src="http://tech.acnow.net/Files/Img/list_nav_spacer.gif"><a Class="a2" href= http://tech.acnow.net/Html/DataBase/Oracle/2005-4/29/164558059816455832996.shtml title="ORACLE SQL性能优化系列 (四)">ORACLE SQL性能优化系列 (四)</a></td></tr>
<tr>
<td Height=1 colspan="1">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td Height=1 background="http://tech.acnow.net/Files/Img/title_line.gif">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><img src="http://tech.acnow.net/Files/Img/list_nav_spacer.gif"><a Class="a2" href= http://tech.acnow.net/Html/DataBase/Oracle/2005-4/29/164558059816455862139.shtml title="ORACLE SQL性能优化系列 (二)">ORACLE SQL性能优化系列 (二)</a></td></tr>
<tr>
<td Height=1 colspan="1">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td Height=1 background="http://tech.acnow.net/Files/Img/title_line.gif">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><img src="http://tech.acnow.net/Files/Img/list_nav_spacer.gif"><a Class="a2" href= http://tech.acnow.net/Html/DataBase/Oracle/2005-4/29/164558059816455833067.shtml title="ORACLE SQL性能优化系列 (七)">ORACLE SQL性能优化系列 (七)</a></td></tr>
<tr>
<td Height=1 colspan="1">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td Height=1 background="http://tech.acnow.net/Files/Img/title_line.gif">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><img src="http://tech.acnow.net/Files/Img/list_nav_spacer.gif"><a Class="a2" href= http://tech.acnow.net/html/SoftWare/SoftwareEducate/OracleAuthentication/2006-5/29/150826355.shtml title="ORACLE SQL性能优化系列 (一)">ORACLE SQL性能优化系列 (一)</a></td></tr>
<tr>
<td Height=1 colspan="1">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td Height=1 background="http://tech.acnow.net/Files/Img/title_line.gif">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><img src="http://tech.acnow.net/Files/Img/list_nav_spacer.gif"><a Class="a2" href= http://tech.acnow.net/Html/DataBase/Oracle/2005-4/29/164559059816455944859.shtml title="ORACLE SQL性能优化系列 (十)">ORACLE SQL性能优化系列 (十)</a></td></tr>
<tr>
<td Height=1 colspan="1">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td Height=1 background="http://tech.acnow.net/Files/Img/title_line.gif">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><img src="http://tech.acnow.net/Files/Img/list_nav_spacer.gif"><a Class="a2" href= http://tech.acnow.net/Html/DataBase/Oracle/2005-4/29/164558059816455832430.shtml title="ORACLE SQL性能优化系列 (九)">ORACLE SQL性能优化系列 (九)</a></td></tr>
<tr>
<td Height=1 colspan="1">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td Height=1 background="http://tech.acnow.net/Files/Img/title_line.gif">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><img src="http://tech.acnow.net/Files/Img/list_nav_spacer.gif"><a Class="a2" href= http://tech.acnow.net/Html/DataBase/Oracle/2005-4/29/164558059816455832253.shtml title="ORACLE SQL性能优化系列 (八)">ORACLE SQL性能优化系列 (八)</a></td></tr>
<tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -