ͨ¹ý·ÖÎöSQLÓï¾äµÄÖ´Ðмƻ®ÓÅ»¯SQL£¨Ò»£©
ÓÅ»¯Æ÷ÔÚÐγÉÖ´Ðмƻ®Ê±ÐèÒª×öµÄÒ»¸öÖØҪѡÔñÊÇÈçºÎ´ÓÊý¾Ý¿â²éѯ³öÐèÒªµÄÊý¾Ý¡£¶ÔÓÚSQLÓï¾ä´æÈ¡µÄÈκαíÖеÄÈκÎÐУ¬¿ÉÄÜ´æÔÚÐí¶à´æȡ·¾¶(´æÈ¡·½·¨)£¬Í¨¹ýËüÃÇ¿ÉÒÔ¶¨Î»ºÍ²éѯ³öÐèÒªµÄÊý¾Ý¡£ÓÅ»¯Æ÷Ñ¡ÔñÆäÖÐ×ÔÈÏΪÊÇ×îÓÅ»¯µÄ·¾¶¡£
¡¡¡¡ÔÚÎïÀí²ã£¬oracle¶ÁÈ¡Êý¾Ý£¬Ò»´Î¶ÁÈ¡µÄ×îСµ¥Î»ÎªÊý¾Ý¿â¿é(Óɶà¸öÁ¬ÐøµÄ²Ù×÷ϵͳ¿é×é³É)£¬Ò»´Î¶ÁÈ¡µÄ×î´óÖµÓɲÙ×÷ϵͳһ´ÎI/OµÄ×î´óÖµÓëmultiblock²ÎÊý¹²Í¬¾ö¶¨£¬ËùÒÔ¼´Ê¹Ö»ÐèÒªÒ»ÐÐÊý¾Ý£¬Ò²Êǽ«¸ÃÐÐËùÔÚµÄÊý¾Ý¿â¿é¶ÁÈëÄÚ´æ¡£Âß¼ÉÏ£¬oracleÓÃÈçÏ´æÈ¡·½·¨·ÃÎÊÊý¾Ý£º
¡¡¡¡(1) È«±íɨÃ裨Full Table Scans, FTS£©
¡¡¡¡ÎªÊµÏÖÈ«±íɨÃ裬Oracle¶ÁÈ¡±íÖÐËùÓеÄÐУ¬²¢¼ì²éÿһÐÐÊÇ·ñÂú×ãÓï¾äµÄWHEREÏÞÖÆÌõ¼þ¡£Oracle˳ÐòµØ¶ÁÈ¡·ÖÅä¸ø±íµÄÿ¸öÊý¾Ý¿é£¬Ö±µ½¶Áµ½±íµÄ×î¸ßË®Ïß´¦(high water mark, HWM£¬±êʶ±íµÄ×îºóÒ»¸öÊý¾Ý¿é)¡£Ò»¸ö¶à¿é¶Á²Ù×÷¿ÉÒÔʹһ´ÎI/OÄܶÁÈ¡¶à¿éÊý¾Ý¿é(db_block_multiblock_read_count²ÎÊýÉ趨)£¬¶ø²»ÊÇÖ»¶ÁÈ¡Ò»¸öÊý¾Ý¿é£¬Õ⼫´óµÄ¼õÉÙÁËI/O×Ü´ÎÊý£¬Ìá¸ßÁËϵͳµÄÍÌÍÂÁ¿£¬ËùÒÔÀûÓöà¿é¶ÁµÄ·½·¨¿ÉÒÔÊ®·Ö¸ßЧµØʵÏÖÈ«±íɨÃ裬¶øÇÒÖ»ÓÐÔÚÈ«±íɨÃèµÄÇé¿öϲÅÄÜʹÓöà¿é¶Á²Ù×÷¡£ÔÚÕâÖÖ·ÃÎÊģʽÏ£¬Ã¿¸öÊý¾Ý¿éÖ»±»¶ÁÒ»´Î¡£ÓÉÓÚHWM±êʶ×îºóÒ»¿é±»¶ÁÈëµÄÊý¾Ý£¬¶ødelete²Ù×÷²»Ó°ÏìHWMÖµ£¬ËùÒÔÒ»¸ö±íµÄËùÓÐÊý¾Ý±»deleteºó£¬ÆäÈ«±íɨÃèµÄʱ¼ä²»»áÓиÄÉÆ£¬Ò»°ãÎÒÃÇÐèҪʹÓÃtruncateÃüÁîÀ´Ê¹HWMÖµ¹éΪ0¡£ÐÒÔ˵ÄÊÇoracle 10Gºó£¬¿ÉÒÔÈ˹¤ÊÕËõHWMµÄÖµ¡£
¡¡¡¡ÓÉFTSģʽ¶ÁÈëµÄÊý¾Ý±»·Åµ½¸ßËÙ»º´æµÄLeast Recently Used (LRU)ÁбíµÄβ²¿£¬ÕâÑù¿ÉÒÔʹÆä¿ìËÙ½»»»³öÄڴ棬´Ó¶ø²»Ê¹ÄÚ´æÖØÒªµÄÊý¾Ý±»½»»»³öÄÚ´æ¡£
¡¡¡¡Ê¹ÓÃFTSµÄÇ°ÌáÌõ¼þ£ºÔڽϴóµÄ±íÉϲ»½¨ÒéʹÓÃÈ«±íɨÃ裬³ý·ÇÈ¡³öÊý¾ÝµÄ±È½Ï¶à£¬³¬¹ý×ÜÁ¿µÄ5% -- 10%£¬»òÄãÏëʹÓò¢Ðвéѯ¹¦ÄÜʱ¡£
ʹÓÃÈ«±íɨÃèµÄÀý×Ó£º~~~~~~~~~~~~~~~~~~~~~~~~
SQL> explain plan for select * from dual;
Query Plan
------------------------------------
SELECT STATEMENT¡¡¡¡ [CHOOSE] Cost=
TABLE ACCESS FULL DUAL
¡¡¡¡(2) ͨ¹ýROWIDµÄ±í´æÈ¡£¨Table Access by ROWID»òrowid lookup£©
¡¡¡¡ÐеÄROWIDÖ¸³öÁ˸ÃÐÐËùÔÚµÄÊý¾ÝÎļþ¡¢Êý¾Ý¿éÒÔ¼°ÐÐÔڸÿéÖеÄλÖã¬ËùÒÔͨ¹ýROWIDÀ´´æÈ¡Êý¾Ý¿ÉÒÔ¿ìËÙ¶¨Î»µ½Ä¿±êÊý¾ÝÉÏ£¬ÊÇOracle´æÈ¡µ¥ÐÐÊý¾ÝµÄ×î¿ì·½·¨¡£
¡¡¡¡ÎªÁËͨ¹ýROWID´æÈ¡±í£¬Oracle Ê×ÏÈÒª»ñÈ¡±»Ñ¡ÔñÐеÄROWID£¬»òÕß´ÓÓï¾äµÄWHERE×Ó¾äÖеõ½£¬»òÕßͨ¹ý±íµÄÒ»¸ö»ò¶à¸öË÷Ò
Ïà¹ØÎĵµ£º
±¾ÎĽÚÑ¡×ÔMSDNµÄÎÄÕ¡¶ÎåÖÖÌá¸ß SQL ÐÔÄܵķ½·¨¡·£¬Ìá³öÈçºÎÌá¸ß»ùÓÚSQL ServerÓ¦ÓóÌÐòµÄÔËÐÐЧÂÊ£¬·Ç³£ÖµµÃÍƼö¡£¶ÔһЩTrafficºÜ¸ßµÄÓ¦ÓÃϵͳ¶øÑÔ£¬ÈçºÎÌá¸ßºÍ¸Ä½øSQLÖ¸ÁÊǷdz£ÖØÒªµÄ£¬Ò²ÊÇÒ»¸öºÜºÃµÄÍ»ÆƵ㡣
*ÎÄÕÂÖ÷Òª°üÀ¨ÈçÏÂһЩÄÚÈÝ£¨Èç¸ÐÐËȤ£¬ÇëÖ±½Ó·ÃÎÊÏÂÃæµÄURLÔĶÁÍêÕûµÄÖÐÓ¢ÎÄÎĵµ£©£º
1, ´Ó INSE ......
treeview.aspxÖдúÂëÈçÏ£º
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="treeview.aspx.cs" Inherits="treeview" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999 ......
ch02
--3-4
select * from orders
where 'México D.F.' in
(select City
from Customers
where Orders.CustomerID = Customers.CustomerID )
--3-5
select * from orders
where 'usa' =
(select Country
from Customers
where Orders.CustomerID = Customers.CustomerID )
--4-1
select * from or ......