| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> How to tune this sql (RULE-Based) ?
This view takes about 18 seconds to run when rule-based and 3 seconds
when cost-based on Oracle 7.3.
So you say, why don't you just use cost-based... well most of the other queries in the database were set up for rule-based and don't work so well when table statistics exist.
So how would I go about making this query work faster in the rule-based environment?
Thanks,
April
SELECT
DISTINCT tblSub_Investments.INVESTMENT#,
tblSub_Investments.SUB_INVESTMENT#,
tblrelease_status_dates.release_status_code,
tblrelease_code_table.STATUS_DESCRIPTION, tblinvestment_drivers.INV_DRIVER#, tblinvestment_drivers.INV_DRIVER_DESCRIPTION,tblinvestment_table.INVESTMENT_DESCRIPTION, tblSub_Investments.SUB_INVESTMENT_DESCRIPTION, tblRELEASE_TABLE.RELEASE_DATE,
tblEmployee.First_Name, tblEmployee.Last_Name, tblEmployee.Phone_Number,
+ (CashFlow_Contract_yr3+CASHFLOW_Interest_Yr3+CASHFLOW_Overhead_yr3+NMCostsYr3)
+ (CashFlow_Contract_yr4+CASHFLOW_Interest_Yr4+CASHFLOW_Overhead_yr4+NMCostsYr4)
+ (CashFlow_Contract_yr5+CASHFLOW_Interest_Yr5+CASHFLOW_Overhead_yr5+NMCostsYr5)
+ (CashFlow_Contract_yr6+CASHFLOW_Interest_Yr6+CASHFLOW_Overhead_yr6+NMCostsYr6)
+ (CashFlow_Contract_yr7+CASHFLOW_Interest_Yr7+CASHFLOW_Overhead_yr7+NMCostsYr7)
+ (CashFlow_Contract_yr8+CASHFLOW_Interest_Yr8+CASHFLOW_Overhead_yr8+NMCostsYr8)
+ (CashFlow_Contract_yr9+CASHFLOW_Interest_Yr9+CASHFLOW_Overhead_yr9+NMCostsYr9)
+ (CashFlow_Contract_yr10+CASHFLOW_Interest_Yr10+CASHFLOW_Overhead_yr10+NMCostsYr10)
AS Amount,
and
tblrelease_table.INVESTMENT# = tblinvestments.investment# and
tblrelease_table.SUB_INVESTMENT# = tblinvestments.sub_investment#
and
tblSub_Investment_Descript.Investment# = tblinvestments.investment#
and
tblSub_Investment_Descript.Sub_Investment# =
tblinvestments.sub_investment# and
tblInvestment_Description.Investment# = tblinvestments.investment#
and
tblinvestment_table.INVESTMENT# = tblinvestments.investment#
and
tblinvestment_drivers.inv_driver# = tblinvestment_table.inv_driver#
and
tblEmployee.Employee# = tblInvestment_Description.Employee#
and
tblrelease_status_dates.release_status_code and
tblrelease_status_dates.release# = tblrelease_Table.release# and
tblrelease_status_dates.investment# = tblrelease_Table.investment#
and
tblrelease_status_dates.sub_investment# =
tblrelease_Table.sub_investment# and
statuscodecheck.release# = tblrelease_Table.release# and
statuscodecheck.investment# = tblrelease_Table.investment# and
statuscodecheck.sub_investment# = tblrelease_Table.sub_investment#
and
a.cancelled = tblrelease_code_table.cancelled) and (tblRELEASE_TABLE.STATUS_CODE > 2) andtblInvestment_Description.EffectiveDate = (select max(a.EffectiveDate) from tblInvestment_Description a where a.Investment# = tblInvestment_Description.Investment# and a.cancelled = tblInvestment_Description.cancelled) and tblInvestment_table.EffectiveDate = (select max(a.EffectiveDate) from tblInvestment_table a where a.Investment# = tblInvestment_table.Investment# and
a.Investment# = tblRELEASE_status_dates.Investment# and a.Sub_Investment# = tblRELEASE_status_dates.Sub_Investment# and a.release_status_code = tblrelease_status_dates.release_status_code) and
a.sub_investment# = tblinvestments.sub_investment# and a.cancelled = tblinvestments.cancelled and a.effectivedate <= tblrelease_status_dates.effectivedate) and tblinvestments.cancelled = 0 and tblrelease_table.cancelled = 0 and tblemployee.cancelled = 0 and tblsub_investment_descript.cancelled = 0 and tblsub_investments.cancelled = 0 and tblinvestment_drivers.cancelled = 0 and tblinvestment_table.cancelled = 0 and tblinvestment_description.cancelled = 0 and tblrelease_code_table.cancelled = 0 andtblinvestment_drivers.INV_DRIVER# in
EXPLAIN PLAN Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Hint=CHOOSE
SORT UNIQUE
FILTER
NESTED LOOPS
NESTED LOOPS
NESTED LOOPS
NESTED LOOPS
NESTED LOOPS
NESTED LOOPS
NESTED LOOPS
NESTED LOOPS
NESTED LOOPS
NESTED LOOPS
TABLE ACCESS BY
ROWID TBLRELEASE_STATUS_DATES
INDEX RANGE SCAN STATUS_CODE5892
TABLE ACCESS BY ROWID TBLRELEASE_TABLE
INDEX RANGE SCAN RELEASE#
TABLE ACCESS BY ROWID TBLRELEASE_STATUS_DATES
AND-EQUAL
INDEX RANGE
SCAN RELEASE_STATUS_DATESRELEAS
INDEX RANGE SCAN SUB_INVESTMENT#
TABLE ACCESS BY ROWID TBLRELEASE_CODE_TABLE
INDEX RANGE SCAN STATUS_CODE_ID
TABLE ACCESS BY ROWID TBLINVESTMENTS
INDEX RANGE SCAN INVESTMENTS
TABLE ACCESS BY ROWID TBLSUB_INVESTMENTS
INDEX RANGE SCAN TBLSUB_INVESTMENTS_ME
TABLE ACCESS BY ROWID TBLSUB_INVESTMENT_DESCRIPT
INDEX RANGE SCAN TBLSUB_INVESTMENT_DESCRIPT_ME
TABLE ACCESS BY ROWID TBLINVESTMENT_TABLE
INDEX RANGE SCAN TBLINVESTMENT_TABLE_ME
TABLE ACCESS BY ROWID TBLINVESTMENT_DRIVERS
INDEX RANGE SCAN TBLINVESTMENT_DRIVERS_ME
TABLE ACCESS BY ROWID TBLINVESTMENT_DESCRIPTION
INDEX RANGE SCAN TBLINVESTMENT_DESCRIPTION_ME
TABLE ACCESS BY ROWID TBLEMPLOYEE
INDEX RANGE SCAN EMPLOYEE_ID
SORT AGGREGATE
TABLE ACCESS BY ROWID TBLRELEASE_CODE_TABLE
INDEX RANGE SCAN STATUS_CODE_ID
SORT AGGREGATE
TABLE ACCESS BY ROWID TBLINVESTMENT_DESCRIPTION
INDEX RANGE SCAN TBLINVESTMENT_DESCRIPTION_ME
SORT AGGREGATE
TABLE ACCESS BY ROWID TBLINVESTMENT_TABLE
INDEX RANGE SCAN TBLINVESTMENT_TABLE_ME
SORT AGGREGATE
TABLE ACCESS BY ROWID TBLINVESTMENT_DRIVERS
INDEX RANGE SCAN TBLINVESTMENT_DRIVERS_ME
SORT AGGREGATE
TABLE ACCESS BY ROWID TBLSUB_INVESTMENTS
INDEX RANGE SCAN TBLSUB_INVESTMENTS_ME
SORT AGGREGATE
TABLE ACCESS BY ROWID TBLSUB_INVESTMENT_DESCRIPT
INDEX RANGE SCAN TBLSUB_INVESTMENT_DESCRIPT_ME
SORT AGGREGATE
TABLE ACCESS BY ROWID TBLEMPLOYEE
INDEX RANGE SCAN EMPLOYEE_ID
SORT AGGREGATE
TABLE ACCESS BY ROWID TBLRELEASE_STATUS_DATES
INDEX RANGE SCAN TBLRELEASE_STATUS_DATES_ME2
SORT AGGREGATE
TABLE ACCESS BY ROWID TBLRELEASE_TABLE
INDEX RANGE SCAN RELEASE#
SORT AGGREGATE
INDEX RANGE SCAN SYS_C001422
Received on Mon Sep 30 2002 - 15:50:46 CDT
![]() |
![]() |