where条件の順序が違っています。性能の異なる例を検討します。
昨日本でSQL文の最適化を見ましたが、whereの条件は順序が違っています。性能が違います。この提案はOracle 11 Gバージョンでは適切ですか?方式1は方式2より優れていますか?方式1:
select a.*
from students s,
class c
where
s.id = c.id
s.id = 'xxxxxxxx'
方式2:
select a.*
from students s,
class c
where
s.id = 'xxxxxxxx'
s.id = c.id
10 gで試験結果は同じであることが証明されます。Microsoft Windows[バージョン5.2.3790](C)版権所有1985-2003 Microsoft Corp.C:\Doccuments and Settings\Administrtor>sqlplus/as sysdba SQL*Plus:Release 10.2.0.0-Production土曜日5月17:48:55 Coght 2005Oracle.All rights reerved.接続先:Oracle Database 10 g Edition Release 10.2.0.0-Prodion With the Parttioning、OLPAP and Data Mining options SQL>alter system flashempoolシステムが変更されましたSQL>alter system flush buffer_cache;システムが変更されましたSQL>set auttrace on;SQL>select*2 from COUNTRIES c、3 REGIONS r 4 where c.REGION_ID=r.REGION_ID and c.REGION_ID='4';REGIONS*3行目にエラーが発生しました。ORA-00942:表やビューが存在しないSQL>select*2 from hr.C.ONTRIES c,3 hr.REGIONS r 4 where c.REGION_ID=r.REGION_ID and c.REGION_ID='4';CO COUNTRY_NAME REGION_ID REGION_ID--------------------------------REGION_NAME----------------EG Egypt 4 Middle East and Africa IL Isral 4 Middle East and Africa KW Kuwait 4 Middle East and Africa CO COUNTRY uNAME REGION_ID REGION_ID--------------------------------REGION_NAME--------------NG Nigeria 4 Middle East and Africa ZM ZM Zambia 4 Middle East and Africa ZW Zimbabwe 4 Middle East and Africaは6行を選択しました。実行計画--------------------------Plan hash value:4030536------------------------------------------------------------------------------------------------------------------------------------------------------------------------|Time|--------------------------------------------------------------------------------------------------?0?0?0:00:01 124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124; 124124124124124124124124124124124124124124124124124124124124124124124; 1241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241(0)|00:00:01?*3|INDEX UNIQUE SCAN REG_ID_PK?1?0(0)124; 00:00:01?*4?INDEX FULL SCAN COUNTRY_C_ID_PK|6|84|1(0)|00:00:01|----------------------------------------------------------------Prodcate Information(identified by operation):------------------------------------------------------------------------------------------------------------------------------------------ID'=4)-filter("C"."REGION_ID「=4)統計情報--------------------------------628 recursive call 0 db block gets 127 consistentgets 20 physical reads 825 bytes sent via SQL*Net to client 385 byteceived vivieedL*Net froromtfrororororororororororomtttttfrororororororororororororororomivividededessssssssssssssssmmmmmclclclclinininininintttttttdddddclclclclinininininclinininininininttt萼33859;菗菗33751;33751;33751;33781;33781;菵菵SQL>alter system fush shared_poolシステムが変更されましたSQL>alter system flush buffer_cache;システムが変更されましたselect*from hr.c.OUTRIES c,hr.REGIONS r where c.REGION_ID=''4'6 and c.REGION_ID=r.REGION_ID;CO COUNTRY_NAME REGION_ID REGION_ID--------------------------------REGION_NAME----------------EG Egypt 4 Middle East and Africa IL Isral 4 Middle East and Africa KW Kuwait 4 Middle East and Africa CO COUNTRY uNAME REGION_ID REGION_ID--------------------------------REGION_NAME--------------NG Nigeria 4 Middle East and Africa ZM ZM Zambia 4 Middle East and Africa ZW Zimbabwe 4 Middle East and Africaは6行を選択しました。実行計画--------------------------Plan hash value:4030536------------------------------------------------------------------------------------------------------------------------------------------------------------------------|Time|--------------------------------------------------------------------------------------------------?0?0?0:00:01 124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124124; 124124124124124124124124124124124124124124124124124124124124124124124; 1241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241(0)|00:00:01?*3|INDEX UNIQUE SCAN REG_ID_PK?1?0(0)124; 00:00:01?*4?INDEX FULL SCAN COUNTRY_C_ID_PK|6|84|1(0)|00:00:01|----------------------------------------------------------------Prodcate Information(identified by operation):------------------------------------------------------------------------------------------------------------------------------------------ID'=4)-filter("C"."REGION_ID「=4)統計情報--------------------------656 recursive cars 0 db block gets 131 consistent gets 22 physical reads 0 redo size 825 bytes sent via SQL*Net to client 385 bytectived vided vided vita SQL*Net from 2