SQL Tuning max + group by
Hi all,
I run this query
select max(prelevement_dt), mpr
from labo_demande
group by mpr;The table labo_demande contains 1.688.883 rows and an index on (MPR, PRELEVEMENT_DT) exists. (I have already rebuilt this index).
I gather stats on the table but the query still takes 10 seconds running.
The explain plan shows a TABLE ACCESS FULL on the table.
Have someone an idea on how to tune this sql statement ?
Thanks for your help
fcjunic wrote:
Hi all,
I run this query
select max(prelevement_dt), mpr
from labo_demande
group by mpr;The table labo_demande contains 1.688.883 rows and an index on (MPR, PRELEVEMENT_DT) exists. (I have already rebuilt this index).
I gather stats on the table but the query still takes 10 seconds running.
The explain plan shows a TABLE ACCESS FULL on the table.
Unless at least one of the two columns is declared to be non-null (or you add a predicate like (e.g.): "mpr is not null") then this is the only possible execution path for the query. If there is a NOT NULL constraint on one of the columns then an index fast full scan with "sort group by "is possible, and an index full scan with "sort group by nosort" is possible - but the cost of the the index full scan could (for valid reasons) be larger than the cost of the tablescan, and there are various bugs with costing index fast full scans that means the optimizer can make the cost of that plan too high (for invalid reasons).
If either of the paths are valid, you can hint them: /*+ index(labo_demande(mpr, prelevement_dt)) */ or /*+ index_ffs(....) */
Regards
Jonathan Lewis
Similar Messages
-
Merging multiple rows without using max group by
Hi guys,
Is there any better way to convert
with
test as
select '001' as id, 'Apple' as name, 'A' as segment1,null as segment2,null as segment3 from dual union all
select '001' as id, 'Apple' as name,null as segment1, 'P' as segment2,null as segment3 from dual union all
select '001' as id, 'Apple' as name,null as segment1,null as segment2, 'L' as segment3 from dual
select * from test
to
select '001' as id, 'Apple' as name, 'A' as segment1,'P' as segment2,'L' as segment3 from dual
without using max and group by?
There are about 5 million records and using max group by is slowing it down by a lot.
It is needed to be done by SQL.
Thank Youwith
test as
select '001' as id, 'Apple' as name, 'A' as segment1,null as segment2,null as segment3 from dual union all
select '001' as id, 'Apple' as name,null as segment1, 'P' as segment2,null as segment3 from dual union all
select '001' as id, 'Apple' as name,null as segment1,null as segment2, 'L' as segment3 from dual
select distinct id, name
, last_value(segment1 ignore nulls) over (partition by id, name order by segment1) as seg1
, last_value(segment2 ignore nulls) over (partition by id, name order by segment2) as seg2
, last_value(segment3 ignore nulls) over (partition by id, name order by segment3) as seg3
from test
;No max or group by, but not necessarily any faster. If you post your actual query, some sample data with expected results, and the additional information requested in the following posts, then someone may be able to provide better suggestions.
When your query takes too long
When your query takes too long ...
How to Post a SQL statement tuning request
HOW TO: Post a SQL statement tuning request - template posting
Regards,
Bob -
SQL tuning advisor in 11G.
Hi,
our dev guys given poor performance query to me to tune.
Can any one able to provide me steps to get recommendation from SQL tuning advisor by creating tuning task for a manually specified statement.
Version : 11.1.0.6.0
OS : SunOS 5.10
Thanks in advance!
GovinHi,
Thanks for your reply,
Creation of SQL Tuning Task failed due to below one,
"to_char(max(r.ts), 'mm/dd/yyyy') viewrequest_lastdate"
saying like
ERROR at line 8:
ORA-06550: line 8, column 22:
PLS-00103: Encountered the symbol "MM" when expecting one of the following:
* & = - + ; < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec between || member submultiset
The symbol "*" was substituted for "MM" to continue.
Then i have replaced with
"to_char(max(r.ts), :bnd) viewrequest_lastdate". After this task is created & executed. Right now, im getting below error.. plz advice.
GENERAL INFORMATION SECTION
Tuning Task Name : my_sql_tuning_task
Tuning Task Owner : SYS
Workload Type : Single SQL Statement
Scope : COMPREHENSIVE
Time Limit(seconds) : 60
Completion Status : COMPLETED
Started at : 10/26/2010 13:36:09
Completed at : 10/26/2010 13:36:13
Schema Name: METRICS
SQL ID : 71kzxnt9vb91q
SQL Text : select p.prfl_id profile_id, p.prfl_src profile_source,
p.prfl_nme profile_name,getDistinctUserIDTypes
(wm_concat(distinct u.usr_ty_cd)) user_id_type,count(distinct
u.usr_id || u.usr_id_src) userid_count, count(e.nttl_id)
entitlement_count,to_char(max(r.ts), :bnd) viewrequest_lastdate
from TABLE1 d, TABLE2 a,TABLE 3 u, TABLE4
e, TABLE 5 r,TABLE6 p, TABLE7 z where
d.dept_id = a.dept_id and d.dept_id = z.dept_id (+) and
a.glbl_id = u.glbl_id and u.usr_id = e.usr_id and u.usr_id_src =
e.usr_id_src and e.prfl_id = p.prfl_id and e.prfl_src =
p.prfl_src and e.lst_rvw_rqst_id = r.rqst_id(+) and (d.mgr_glbid
= :bnd OR z.TO_GLBL_ID = :bnd) and p.prfl_id is not null group
by p.prfl_id, p.prfl_src, p.prfl_nme order by p.prfl_id
ERRORS SECTION
- ORA-01008: not all variables bound
Thanks
Govin -
Need Help in sql tuning in EXADATA environment
I am uploadin the sql with its current explain plan, this sql in Prd database is executing in 6-10 mins and we need to improve this sql perf to 1-2 mins as the requirement from business team.
I am giving some backgroud about this sql tuning requirement, this sql is newly developed in and currently is in UAT phase, we don't have much option for tuning code here since the sql is tool generated through COGNOS DataMart tool, options are there to look into from DBA end with plan level or creating indexes on suitible columns to reduce i/o in minimizing the rows traversing by the sql.
Is anybody can help me out here?
WITH "WCRS_CLAIM_DETAIL_VW5"
AS (SELECT "WCRS_CLAIM_DETAIL_VW"."CLAIM_DETAIL_PK_ID"
"CLAIM_DETAIL_PK_ID",
"WCRS_CLAIM_DETAIL_VW"."CLAIM_ID" "CLAIM_ID",
"WCRS_CLAIM_DETAIL_VW"."CURRENT_SNAPSHOT_IND"
"CURRENT_SNAPSHOT_IND",
"WCRS_CLAIM_DETAIL_VW"."LOSS_DT" "LOSS_DT",
"WCRS_CLAIM_DETAIL_VW"."REGULATORY_STATE_CD"
"REGULATORY_STATE_CD"
FROM "CDW_DLV_IDS"."WCRS_CLAIM_DETAIL_VW" "WCRS_CLAIM_DETAIL_VW"
WHERE "WCRS_CLAIM_DETAIL_VW"."CURRENT_SNAPSHOT_IND" = 'Y'),
"WCRS_POLICY_DETAIL_VW7"
AS (SELECT "WCRS_POLICY_DETAIL_VW"."CLAIM_NBR" "CLAIM_NBR",
"WCRS_POLICY_DETAIL_VW"."CLAIM_SYMBOL_CD" "CLAIM_SYMBOL_CD",
"WCRS_POLICY_DETAIL_VW"."CURRENT_SNAPSHOT_IND"
"CURRENT_SNAPSHOT_IND",
"WCRS_POLICY_DETAIL_VW"."KEY_OFFICE_CD" "KEY_OFFICE_CD",
"WCRS_POLICY_DETAIL_VW"."POLICY_NBR" "POLICY_NBR"
FROM "CDW_DLV_IDS"."WCRS_POLICY_DETAIL_VW" "WCRS_POLICY_DETAIL_VW"
WHERE "WCRS_POLICY_DETAIL_VW"."CURRENT_SNAPSHOT_IND" = 'Y')
SELECT /*+ gather_plan_statistics monitor bind_aware */
/* ^^unique_id */
"T0"."C0" "Account_Name",
"T0"."C1" "Accident_State_Cd",
"T0"."C2" "c3",
"T0"."C3" "PPO_Name",
"T0"."C4" "Invc_Classification_Type_Desc",
FIRST_VALUE (
"T0"."C5")
OVER (
PARTITION BY "T0"."C0",
"T0"."C1",
"T0"."C2",
"T0"."C3",
"T0"."C4",
"T0"."C6")
"Claim_Cnt___Distinct",
"T0"."C7" "Invc_Control_Number",
"T0"."C8" "Invc_Allowance_Amt",
"T0"."C9" "Invc_Charge_Amt",
"T0"."C10" "c10",
"T0"."C11" "PPO_Reduction_Amt",
"T0"."C12" "Dup_Ln_Save_Amt",
"T0"."C13" "c13",
"T0"."C14" "Sub_Total",
"T0"."C15" "c15",
"T0"."C6" "c16"
FROM (SELECT "T1"."C0" "C0",
"T1"."C1" "C1",
"T1"."C2" "C2",
"T1"."C3" "C3",
"T1"."C4" "C4",
"T1"."C6" "C5",
"T1"."C5" "C6",
"T0"."C0" "C7",
"T1"."C7" "C8",
"T1"."C8" "C9",
"T1"."C9" "C10",
"T1"."C10" "C11",
"T1"."C11" "C12",
"T1"."C12" "C13",
"T1"."C13" "C14",
"T1"."C14" "C15"
FROM (SELECT COUNT (DISTINCT "INVC_DIM_VW"."INVC_ID") "C0"
FROM "CDW_DLV_IDS"."WCRS_POLICY_GROUPING_VW" "WCRS_POLICY_GROUPING_VW",
"WCRS_CLAIM_DETAIL_VW5",
"EDW_DM"."INVC_DIM_VW" "INVC_DIM_VW",
"EDW_DM"."PROVIDER_NETWORK_DIM_VW" "PROVIDER_NETWORK_DIM_VW",
"EDW_DM"."INVC_ACTY_SNPSHT_FACT_VW" "INVC_ACTY_SNPSHT_FACT_VW6",
"EDW_DM"."CURRENT_MED_INVC_RPT_DT_VW" "CURRENT_MED_INVC_RPT_DT_VW",
"EDW_DM"."ALL_INVC_SNPSHT_FACT_VW" "ALL_INVC_SNPSHT_FACT_VW",
"CDW_DLV_IDS"."WCRS_CURRENT_CLAIM_RPT_DT_VW" "WCRS_CURRENT_CLAIM_RPT_DT_VW",
"CDW_DLV_IDS"."WCRS_CLAIM_FACT_VW" "WCRS_CLAIM_FACT_VW",
"WCRS_POLICY_DETAIL_VW7",
"EDW_DM"."INVC_CLAIM_DTL_BRDG_FACT_VW" "INVC_CLAIM_DTL_BRDG_FACT_VW"
WHERE "INVC_DIM_VW"."INVC_DELETION_IND" <> 'Y'
AND "INVC_DIM_VW"."INVC_CONSIDRTN_TYPE_DESC" =
'Original'
AND "CURRENT_MED_INVC_RPT_DT_VW"."CURRENT_MONTH_RPT_DT" =
"ALL_INVC_SNPSHT_FACT_VW"."AS_OF_MONTH_END_DT_PK_ID"
AND "WCRS_CURRENT_CLAIM_RPT_DT_VW"."CURRENT_CLAIM_RPT_DT" =
"WCRS_CLAIM_FACT_VW"."CLAIM_REPORTING_DT"
AND "WCRS_POLICY_GROUPING_VW"."ACCOUNT_NM" =
CAST ('1ST TEAM STAFFING SERVICES, INC.' AS VARCHAR (50 CHAR))
AND "WCRS_POLICY_DETAIL_VW7"."POLICY_NBR" =
"WCRS_POLICY_GROUPING_VW"."POLICY_IDENTIFIER"
AND "WCRS_POLICY_DETAIL_VW7"."CLAIM_NBR" =
"WCRS_CLAIM_FACT_VW"."CLAIM_NBR"
AND "WCRS_POLICY_DETAIL_VW7"."CLAIM_SYMBOL_CD" =
"WCRS_CLAIM_FACT_VW"."CLAIM_SYMBOL_CD"
AND "WCRS_POLICY_DETAIL_VW7"."KEY_OFFICE_CD" =
"WCRS_CLAIM_FACT_VW"."KEY_OFFICE_CD"
AND "WCRS_POLICY_DETAIL_VW7"."CURRENT_SNAPSHOT_IND" =
'Y'
AND "WCRS_CLAIM_FACT_VW"."CLAIM_DETAIL_PK_ID" =
"WCRS_CLAIM_DETAIL_VW5"."CLAIM_DETAIL_PK_ID"
AND "WCRS_CLAIM_DETAIL_VW5"."CURRENT_SNAPSHOT_IND" =
'Y'
AND "WCRS_CLAIM_FACT_VW"."CLAIM_GID" =
"INVC_CLAIM_DTL_BRDG_FACT_VW"."CLM_GID"
AND "INVC_CLAIM_DTL_BRDG_FACT_VW"."INVC_GID" =
"INVC_DIM_VW"."INVC_GID"
AND "INVC_DIM_VW"."INVC_PK_ID" =
"INVC_ACTY_SNPSHT_FACT_VW6"."INVC_PK_ID"
AND "ALL_INVC_SNPSHT_FACT_VW"."MONTH_END_DT_PK_ID" =
"INVC_ACTY_SNPSHT_FACT_VW6"."MONTH_END_DT_PK_ID"
AND "ALL_INVC_SNPSHT_FACT_VW"."INVC_GID" =
"INVC_ACTY_SNPSHT_FACT_VW6"."INVC_GID"
AND "PROVIDER_NETWORK_DIM_VW"."PROVIDER_NETWORK_PK_ID" =
"INVC_ACTY_SNPSHT_FACT_VW6"."PPO_PROVIDER_NETWORK_PK_ID"
AND "WCRS_CURRENT_CLAIM_RPT_DT_VW"."CURRENT_CLAIM_RPT_DT" =
"WCRS_CLAIM_FACT_VW"."CLAIM_REPORTING_DT") "T0",
( SELECT "WCRS_POLICY_GROUPING_VW"."ACCOUNT_NM" "C0",
"WCRS_CLAIM_DETAIL_VW5"."REGULATORY_STATE_CD" "C1",
CASE
WHEN "INVC_DIM_VW"."INVC_IN_OUT_OF_NETWORK_IND" =
'Y'
THEN
'In - Network'
WHEN "INVC_DIM_VW"."INVC_IN_OUT_OF_NETWORK_IND" =
'N'
THEN
'Out - Network'
ELSE
'Others'
END
"C2",
"PROVIDER_NETWORK_DIM_VW"."PROVIDER_NETWORK_NM" "C3",
"INVC_DIM_VW"."INVC_CLASS_TYPE_DESC" "C4",
CASE
WHEN (EXTRACT (
YEAR FROM ("WCRS_CLAIM_DETAIL_VW5"."LOSS_DT"))
IS NULL)
OR (EXTRACT (
MONTH FROM ("WCRS_CLAIM_DETAIL_VW5"."LOSS_DT"))
IS NULL)
THEN
NULL
ELSE
( EXTRACT (
YEAR FROM ("WCRS_CLAIM_DETAIL_VW5"."LOSS_DT"))
|| EXTRACT (
MONTH FROM ("WCRS_CLAIM_DETAIL_VW5"."LOSS_DT")))
END
"C5",
COUNT (DISTINCT "WCRS_CLAIM_DETAIL_VW5"."CLAIM_ID")
"C6",
SUM ("INVC_ACTY_SNPSHT_FACT_VW6"."INVC_ALWC_AMT") "C7",
SUM ("INVC_ACTY_SNPSHT_FACT_VW6"."INVC_CHRGS_AMT")
"C8",
SUM (
"INVC_ACTY_SNPSHT_FACT_VW6"."TOT_INVC_REVIEW_RULE_ALWC_AMT")
"C9",
SUM ("INVC_ACTY_SNPSHT_FACT_VW6"."INVC_PPO_REDUC_AMT")
"C10",
SUM ("INVC_ACTY_SNPSHT_FACT_VW6"."INVC_DUP_REDUC_AMT")
"C11",
SUM ("INVC_ACTY_SNPSHT_FACT_VW6"."INVC_OSR_REDUC_AMT")
"C12",
( SUM (
"INVC_ACTY_SNPSHT_FACT_VW6"."INVC_CHRGS_AMT")
- SUM ("INVC_ACTY_SNPSHT_FACT_VW6"."INVC_ALWC_AMT"))
- SUM (
"INVC_ACTY_SNPSHT_FACT_VW6"."INVC_DUP_REDUC_AMT")
"C13",
SUM (
"INVC_ACTY_SNPSHT_FACT_VW6"."INVC_CLNT_SPEC_REDUC_AMT")
"C14"
FROM "CDW_DLV_IDS"."WCRS_POLICY_GROUPING_VW" "WCRS_POLICY_GROUPING_VW",
"WCRS_CLAIM_DETAIL_VW5",
"EDW_DM"."INVC_DIM_VW" "INVC_DIM_VW",
"EDW_DM"."PROVIDER_NETWORK_DIM_VW" "PROVIDER_NETWORK_DIM_VW",
"EDW_DM"."INVC_ACTY_SNPSHT_FACT_VW" "INVC_ACTY_SNPSHT_FACT_VW6",
"EDW_DM"."CURRENT_MED_INVC_RPT_DT_VW" "CURRENT_MED_INVC_RPT_DT_VW",
"EDW_DM"."ALL_INVC_SNPSHT_FACT_VW" "ALL_INVC_SNPSHT_FACT_VW",
"CDW_DLV_IDS"."WCRS_CURRENT_CLAIM_RPT_DT_VW" "WCRS_CURRENT_CLAIM_RPT_DT_VW",
"CDW_DLV_IDS"."WCRS_CLAIM_FACT_VW" "WCRS_CLAIM_FACT_VW",
"WCRS_POLICY_DETAIL_VW7",
"EDW_DM"."INVC_CLAIM_DTL_BRDG_FACT_VW" "INVC_CLAIM_DTL_BRDG_FACT_VW"
WHERE "INVC_DIM_VW"."INVC_DELETION_IND" <> 'Y'
AND "INVC_DIM_VW"."INVC_CONSIDRTN_TYPE_DESC" =
'Original'
AND "CURRENT_MED_INVC_RPT_DT_VW"."CURRENT_MONTH_RPT_DT" =
"ALL_INVC_SNPSHT_FACT_VW"."AS_OF_MONTH_END_DT_PK_ID"
AND "WCRS_CURRENT_CLAIM_RPT_DT_VW"."CURRENT_CLAIM_RPT_DT" =
"WCRS_CLAIM_FACT_VW"."CLAIM_REPORTING_DT"
AND "WCRS_POLICY_GROUPING_VW"."ACCOUNT_NM" =
CAST ('1ST TEAM STAFFING SERVICES, INC.' AS VARCHAR (50 CHAR))
AND "WCRS_POLICY_DETAIL_VW7"."POLICY_NBR" =
"WCRS_POLICY_GROUPING_VW"."POLICY_IDENTIFIER"
AND "WCRS_POLICY_DETAIL_VW7"."CLAIM_NBR" =
"WCRS_CLAIM_FACT_VW"."CLAIM_NBR"
AND "WCRS_POLICY_DETAIL_VW7"."CLAIM_SYMBOL_CD" =
"WCRS_CLAIM_FACT_VW"."CLAIM_SYMBOL_CD"
AND "WCRS_POLICY_DETAIL_VW7"."KEY_OFFICE_CD" =
"WCRS_CLAIM_FACT_VW"."KEY_OFFICE_CD"
AND "WCRS_POLICY_DETAIL_VW7"."CURRENT_SNAPSHOT_IND" =
'Y'
AND "WCRS_CLAIM_FACT_VW"."CLAIM_DETAIL_PK_ID" =
"WCRS_CLAIM_DETAIL_VW5"."CLAIM_DETAIL_PK_ID"
AND "WCRS_CLAIM_DETAIL_VW5"."CURRENT_SNAPSHOT_IND" =
'Y'
AND "WCRS_CLAIM_FACT_VW"."CLAIM_GID" =
"INVC_CLAIM_DTL_BRDG_FACT_VW"."CLM_GID"
AND "INVC_CLAIM_DTL_BRDG_FACT_VW"."INVC_GID" =
"INVC_DIM_VW"."INVC_GID"
AND "INVC_DIM_VW"."INVC_PK_ID" =
"INVC_ACTY_SNPSHT_FACT_VW6"."INVC_PK_ID"
AND "ALL_INVC_SNPSHT_FACT_VW"."MONTH_END_DT_PK_ID" =
"INVC_ACTY_SNPSHT_FACT_VW6"."MONTH_END_DT_PK_ID"
AND "ALL_INVC_SNPSHT_FACT_VW"."INVC_GID" =
"INVC_ACTY_SNPSHT_FACT_VW6"."INVC_GID"
AND "PROVIDER_NETWORK_DIM_VW"."PROVIDER_NETWORK_PK_ID" =
"INVC_ACTY_SNPSHT_FACT_VW6"."PPO_PROVIDER_NETWORK_PK_ID"
AND "WCRS_CURRENT_CLAIM_RPT_DT_VW"."CURRENT_CLAIM_RPT_DT" =
"WCRS_CLAIM_FACT_VW"."CLAIM_REPORTING_DT"
GROUP BY "WCRS_POLICY_GROUPING_VW"."ACCOUNT_NM",
"WCRS_CLAIM_DETAIL_VW5"."REGULATORY_STATE_CD",
CASE
WHEN "INVC_DIM_VW"."INVC_IN_OUT_OF_NETWORK_IND" =
'Y'
THEN
'In - Network'
WHEN "INVC_DIM_VW"."INVC_IN_OUT_OF_NETWORK_IND" =
'N'
THEN
'Out - Network'
ELSE
'Others'
END,
"PROVIDER_NETWORK_DIM_VW"."PROVIDER_NETWORK_NM",
"INVC_DIM_VW"."INVC_CLASS_TYPE_DESC",
CASE
WHEN (EXTRACT (
YEAR FROM ("WCRS_CLAIM_DETAIL_VW5"."LOSS_DT"))
IS NULL)
OR (EXTRACT (
MONTH FROM ("WCRS_CLAIM_DETAIL_VW5"."LOSS_DT"))
IS NULL)
THEN
NULL
ELSE
( EXTRACT (
YEAR FROM ("WCRS_CLAIM_DETAIL_VW5"."LOSS_DT"))
|| EXTRACT (
MONTH FROM ("WCRS_CLAIM_DETAIL_VW5"."LOSS_DT")))
END) "T1") "T0"
ORDER BY "Account_Name" ASC NULLS LAST,
"Accident_State_Cd" ASC NULLS LAST,
"c3" ASC NULLS LAST,
"PPO_Name" ASC NULLS LAST,
"Invc_Classification_Type_Desc" ASC NULLS LAST| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 1 | 838 | 1079K (1)| 00:00:34 | | |
| 1 | TEMP TABLE TRANSFORMATION | | | | | | | |
| 2 | PX COORDINATOR | | | | | | | |
| 3 | PX SEND QC (RANDOM) | :TQ10000 | 10M| 317M| 848K (1)| 00:00:27 | | |
| 4 | LOAD AS SELECT | SYS_TEMP_0FD9D677A_286AAA2E | | | | | | |
| 5 | PX BLOCK ITERATOR | | 10M| 317M| 848K (1)| 00:00:27 | | |
|* 6 | TABLE ACCESS STORAGE FULL | WCRS_CLAIM_DETAIL | 10M| 317M| 848K (1)| 00:00:27 | | |
| 7 | PX COORDINATOR | | | | | | | |
| 8 | PX SEND QC (RANDOM) | :TQ20000 | 10M| 268M| 44875 (1)| 00:00:02 | | |
| 9 | LOAD AS SELECT | SYS_TEMP_0FD9D677B_286AAA2E | | | | | | |
| 10 | PX BLOCK ITERATOR | | 10M| 268M| 44875 (1)| 00:00:02 | | |
|* 11 | TABLE ACCESS STORAGE FULL | WCRS_POLICY_DETAIL | 10M| 268M| 44875 (1)| 00:00:02 | | |
| 12 | PX COORDINATOR | | | | | | | |
| 13 | PX SEND QC (ORDER) | :TQ40017 | 1 | 838 | 186K (2)| 00:00:06 | | |
| 14 | WINDOW SORT | | 1 | 838 | 186K (2)| 00:00:06 | | |
| 15 | PX RECEIVE | | 1 | 838 | 186K (2)| 00:00:06 | | |
| 16 | PX SEND RANGE | :TQ40016 | 1 | 838 | 186K (2)| 00:00:06 | | |
| 17 | NESTED LOOPS | | 1 | 838 | 186K (2)| 00:00:06 | | |
| 18 | BUFFER SORT | | | | | | | |
| 19 | PX RECEIVE | | | | | | | |
| 20 | PX SEND BROADCAST | :TQ40001 | | | | | | |
| 21 | VIEW | | 1 | 13 | 93216 (2)| 00:00:03 | | |
| 22 | SORT GROUP BY | | 1 | 393 | | | | |
| 23 | PX COORDINATOR | | | | | | | |
| 24 | PX SEND QC (RANDOM) | :TQ30015 | 1 | 393 | | | | |
| 25 | SORT GROUP BY | | 1 | 393 | | | | |
| 26 | PX RECEIVE | | 1 | 393 | | | | |
| 27 | PX SEND HASH | :TQ30014 | 1 | 393 | | | | |
| 28 | SORT GROUP BY | | 1 | 393 | | | | |
|* 29 | HASH JOIN ANTI | | 1 | 393 | 93216 (2)| 00:00:03 | | |
| 30 | PX RECEIVE | | 1 | 376 | 85197 (2)| 00:00:03 | | |
| 31 | PX SEND HASH | :TQ30012 | 1 | 376 | 85197 (2)| 00:00:03 | | |
| 32 | BUFFER SORT | | 1 | 838 | | | | |
| 33 | NESTED LOOPS | | 1 | 376 | 85197 (2)| 00:00:03 | | |
| 34 | NESTED LOOPS | | 1 | 358 | 85197 (2)| 00:00:03 | | |
| 35 | NESTED LOOPS | | 1 | 348 | 85197 (2)| 00:00:03 | | |
|* 36 | HASH JOIN ANTI | | 1 | 316 | 85179 (2)| 00:00:03 | | |
| 37 | PX RECEIVE | | 4 | 1156 | 77161 (2)| 00:00:03 | | |
| 38 | PX SEND HASH | :TQ30010 | 4 | 1156 | 77161 (2)| 00:00:03 | | |
|* 39 | HASH JOIN ANTI BUFFERED | | 4 | 1156 | 77161 (2)| 00:00:03 | | |
| 40 | PX RECEIVE | | 371 | 94605 | 69142 (2)| 00:00:03 | | |
| 41 | PX SEND HASH | :TQ30008 | 371 | 94605 | 69142 (2)| 00:00:03 | | |
|* 42 | HASH JOIN | | 371 | 94605 | 69142 (2)| 00:00:03 | | |
| 43 | PX RECEIVE | | 350 | 77000 | 36642 (1)| 00:00:02 | | |
| 44 | PX SEND BROADCAST | :TQ30007 | 350 | 77000 | 36642 (1)| 00:00:02 | | |
|* 45 | HASH JOIN | | 350 | 77000 | 36642 (1)| 00:00:02 | | |
| 46 | PX RECEIVE | | 140 | 25200 | 28624 (1)| 00:00:01 | | |
| 47 | PX SEND BROADCAST | :TQ30006 | 140 | 25200 | 28624 (1)| 00:00:01 | | |
|* 48 | HASH JOIN | | 140 | 25200 | 28624 (1)| 00:00:01 | | |
| 49 | PX RECEIVE | | 140 | 22820 | 25169 (1)| 00:00:01 | | |
| 50 | PX SEND BROADCAST | :TQ30005 | 140 | 22820 | 25169 (1)| 00:00:01 | | |
|* 51 | HASH JOIN BUFFERED | | 140 | 22820 | 25169 (1)| 00:00:01 | | |
| 52 | BUFFER SORT | | | | | | | |
| 53 | PX RECEIVE | | 9 | 306 | 5 (0)| 00:00:01 | | |
| 54 | T PX SEND BROADCAS | :TQ30000 | 9 | 306 | 5 (0)| 00:00:01 | | |
| 55 | INDEX ROWID TABLE ACCESS BY | WCRS_POLICY_GROUPING | 9 | 306 | 5 (0)| 00:00:01 | | |
|* 56 | AN INDEX RANGE SC | SUK3 | 9 | | 1 (0)| 00:00:01 | | |
|* 57 | HASH JOIN | | 9699K| 1193M| 25149 (1)| 00:00:01 | | |
| 58 | PX RECEIVE | | 9699K| 434M| 22205 (1)| 00:00:01 | | |
| 59 | PX SEND HASH | :TQ30003 | 9699K| 434M| 22205 (1)| 00:00:01 | | |
| 60 | NESTED LOOPS | | 9699K| 434M| 22205 (1)| 00:00:01 | | |
| 61 | BUFFER SORT | | | | | | | |
| 62 | PX RECEIVE | | | | | | | |
| 63 | DCAST PX SEND BROA | :TQ30002 | | | | | | |
| 64 | CARTESIAN MERGE JOIN | | 1 | 14 | 13 (0)| 00:00:01 | | |
| 65 | TERATOR PX BLOCK I | | 1 | 8 | 10 (0)| 00:00:01 | | |
| 66 | ESS STORAGE FULL TABLE ACC | CURRENT_MED_INVC_RPT_DT | 1 | 8 | 10 (0)| 00:00:01 | | |
| 67 | T BUFFER SOR | | 1 | 6 | 3 (0)| 00:00:01 | | |
| 68 | E PX RECEIV | | 1 | 6 | 2 (0)| 00:00:01 | | |
| 69 | BROADCAST PX SEND | :TQ30001 | 1 | 6 | 2 (0)| 00:00:01 | | |
| 70 | K ITERATOR PX BLOC | | 1 | 6 | 2 (0)| 00:00:01 | | |
| 71 | ACCESS STORAGE FULL TABLE | WCRS_CURRENT_CLAIM_RPT_DT | 1 | 6 | 2 (0)| 00:00:01 | | |
| 72 | TOR PX BLOCK ITERA | | 9699K| 305M| 22192 (1)| 00:00:01 | KEY | KEY |
|* 73 | STORAGE FULL TABLE ACCESS | WCRS_CURRENT_CLAIM_FACT | 9699K| 305M| 22192 (1)| 00:00:01 | KEY | KEY |
| 74 | PX RECEIVE | | 10M| 785M| 2907 (2)| 00:00:01 | | |
| 75 | PX SEND HASH | :TQ30004 | 10M| 785M| 2907 (2)| 00:00:01 | | |
|* 76 | VIEW | | 10M| 785M| 2907 (2)| 00:00:01 | | |
| 77 | TOR PX BLOCK ITERA | | 10M| 268M| 2907 (2)| 00:00:01 | | |
| 78 | STORAGE FULL TABLE ACCESS | SYS_TEMP_0FD9D677B_286AAA2E | 10M| 268M| 2907 (2)| 00:00:01 | | |
|* 79 | VIEW | | 10M| 168M| 3439 (2)| 00:00:01 | | |
| 80 | PX BLOCK ITERATOR | | 10M| 317M| 3439 (2)| 00:00:01 | | |
| 81 | E FULL TABLE ACCESS STORAG | SYS_TEMP_0FD9D677A_286AAA2E | 10M| 317M| 3439 (2)| 00:00:01 | | |
| 82 | PX BLOCK ITERATOR | | 15M| 599M| 7994 (1)| 00:00:01 | | |
| 83 | LL TABLE ACCESS STORAGE FU | INVC_CLAIM_DTL_BRDG_FACT | 15M| 599M| 7994 (1)| 00:00:01 | | |
| 84 | PX BLOCK ITERATOR | | 15M| 521M| 32477 (2)| 00:00:02 | | |
|* 85 | TABLE ACCESS STORAGE FULL | INVC_DIM | 15M| 521M| 32477 (2)| 00:00:02 | | |
| 86 | PX RECEIVE | | 15M| 509M| 7994 (1)| 00:00:01 | | |
| 87 | PX SEND HASH | :TQ30009 | 15M| 509M| 7994 (1)| 00:00:01 | | |
| 88 | PX BLOCK ITERATOR | | 15M| 509M| 7994 (1)| 00:00:01 | | |
| 89 | TABLE ACCESS STORAGE FULL | INVC_CLAIM_DTL_BRDG_FACT | 15M| 509M| 7994 (1)| 00:00:01 | | |
| 90 | PX RECEIVE | | 15M| 404M| 7994 (1)| 00:00:01 | | |
| 91 | PX SEND HASH | :TQ30011 | 15M| 404M| 7994 (1)| 00:00:01 | | |
| 92 | PX BLOCK ITERATOR | | 15M| 404M| 7994 (1)| 00:00:01 | | |
| 93 | TABLE ACCESS STORAGE FULL | INVC_CLAIM_DTL_BRDG_FACT | 15M| 404M| 7994 (1)| 00:00:01 | | |
| 94 | TABLE ACCESS BY INDEX ROWID | INVC_ACTY_SNPSHT_FACT | 1 | 32 | 18 (0)| 00:00:01 | | |
|* 95 | INDEX RANGE SCAN | IFK_XPKINVOICE_ACTIVITY_SNAPSH | 1 | | 1 (0)| 00:00:01 | | |
|* 96 | INDEX UNIQUE SCAN | IFK_XPKPROVIDER_NETWORK_DIM | 1 | 10 | 0 (0)| 00:00:01 | | |
|* 97 | INDEX RANGE SCAN | IFK_XPKALL_INVC_SNPSHT_FACT | 1 | 18 | 1 (0)| 00:00:01 | | |
| 98 | PX RECEIVE | | 15M| 254M| 7994 (1)| 00:00:01 | | |
| 99 | PX SEND HASH | :TQ30013 | 15M| 254M| 7994 (1)| 00:00:01 | | |
| 100 | PX BLOCK ITERATOR | | 15M| 254M| 7994 (1)| 00:00:01 | | |
| 101 | TABLE ACCESS STORAGE FULL | INVC_CLAIM_DTL_BRDG_FACT | 15M| 254M| 7994 (1)| 00:00:01 | | |
| 102 | VIEW | | 1 | 825 | | | | |
| 103 | SORT GROUP BY | | 1 | 430 | 93216 (2)| 00:00:03 | | |
| 104 | BUFFER SORT | | | | | | | |
| 105 | PX RECEIVE | | 1 | 430 | 93216 (2)| 00:00:03 | | |
| 106 | PX SEND HASH | :TQ40015 | 1 | 430 | 93216 (2)| 00:00:03 | | |
|*107 | HASH JOIN ANTI BUFFERED | | 1 | 430 | 93216 (2)| 00:00:03 | | |
| 108 | PX RECEIVE | | 1 | 413 | 85198 (2)| 00:00:03 | | |
| 109 | PX SEND HASH | :TQ40013 | 1 | 413 | 85198 (2)| 00:00:03 | | |
| 110 | BUFFER SORT | | 1 | 838 | | | | |
| 111 | NESTED LOOPS | | 1 | 413 | 85198 (2)| 00:00:03 | | |
| 112 | NESTED LOOPS | | 1 | 395 | 85197 (2)| 00:00:03 | | |
| 113 | NESTED LOOPS | | 1 | 369 | 85197 (2)| 00:00:03 | | |
|*114 | HASH JOIN ANTI | | 1 | 311 | 85179 (2)| 00:00:03 | | |
| 115 | PX RECEIVE | | 4 | 1136 | 77161 (2)| 00:00:03 | | |
| 116 | PX SEND HASH | :TQ40011 | 4 | 1136 | 77161 (2)| 00:00:03 | | |
|*117 | HASH JOIN ANTI BUFFERED | | 4 | 1136 | 77161 (2)| 00:00:03 | | |
| 118 | PX RECEIVE | | 371 | 92750 | 69143 (2)| 00:00:03 | | |
| 119 | PX SEND HASH | :TQ40009 | 371 | 92750 | 69143 (2)| 00:00:03 | | |
|*120 | HASH JOIN | | 371 | 92750 | 69143 (2)| 00:00:03 | | |
| 121 | PX RECEIVE | | 350 | 72450 | 36642 (1)| 00:00:02 | | |
| 122 | PX SEND BROADCAST | :TQ40008 | 350 | 72450 | 36642 (1)| 00:00:02 | | |
|*123 | HASH JOIN | | 350 | 72450 | 36642 (1)| 00:00:02 | | |
| 124 | PX RECEIVE | | 140 | 23380 | 28624 (1)| 00:00:01 | | |
| 125 | PX SEND BROADCAST | :TQ40007 | 140 | 23380 | 28624 (1)| 00:00:01 | | |
|*126 | HASH JOIN | | 140 | 23380 | 28624 (1)| 00:00:01 | | |
| 127 | PX RECEIVE | | 140 | 15540 | 25169 (1)| 00:00:01 | | |
| 128 | PX SEND BROADCAST | :TQ40006 | 140 | 15540 | 25169 (1)| 00:00:01 | | |
|*129 | HASH JOIN BUFFERED | | 140 | 15540 | 25169 (1)| 00:00:01 | | |
| 130 | BUFFER SORT | | | | | | | |
| 131 | PX RECEIVE | | 9 | 306 | 5 (0)| 00:00:01 | | |
| 132 | PX SEND BROADCAST | :TQ40000 | 9 | 306 | 5 (0)| 00:00:01 | | |
| 133 | ROWID TABLE ACCESS BY INDEX | WCRS_POLICY_GROUPING | 9 | 306 | 5 (0)| 00:00:01 | | |
|*134 | INDEX RANGE SCAN | SUK3 | 9 | | 1 (0)| 00:00:01 | | |
|*135 | HASH JOIN | | 9699K| 712M| 25149 (1)| 00:00:01 | | |
| 136 | PX RECEIVE | | 10M| 287M| 2907 (2)| 00:00:01 | | |
| 137 | PX SEND HASH | :TQ40004 | 10M| 287M| 2907 (2)| 00:00:01 | | |
|*138 | VIEW | | 10M| 287M| 2907 (2)| 00:00:01 | | |
| 139 | PX BLOCK ITERATOR | | 10M| 268M| 2907 (2)| 00:00:01 | | |
| 140 | E FULL TABLE ACCESS STORAG | SYS_TEMP_0FD9D677B_286AAA2E | 10M| 268M| 2907 (2)| 00:00:01 | | |
| 141 | PX RECEIVE | | 9699K| 434M| 22205 (1)| 00:00:01 | | |
| 142 | PX SEND HASH | :TQ40005 | 9699K| 434M| 22205 (1)| 00:00:01 | | |
| 143 | NESTED LOOPS | | 9699K| 434M| 22205 (1)| 00:00:01 | | |
| 144 | BUFFER SORT | | | | | | | |
| 145 | PX RECEIVE | | | | | | | |
| 146 | PX SEND BROADCAST | :TQ40003 | | | | | | |
| 147 | IAN MERGE JOIN CARTES | | 1 | 14 | 13 (0)| 00:00:01 | | |
| 148 | R PX BLOCK ITERATO | | 1 | 8 | 10 (0)| 00:00:01 | | |
| 149 | ORAGE FULL TABLE ACCESS ST | CURRENT_MED_INVC_RPT_DT | 1 | 8 | 10 (0)| 00:00:01 | | |
| 150 | BUFFER SORT | | 1 | 6 | 3 (0)| 00:00:01 | | |
| 151 | PX RECEIVE | | 1 | 6 | 2 (0)| 00:00:01 | | |
| 152 | AST PX SEND BROADC | :TQ40002 | 1 | 6 | 2 (0)| 00:00:01 | | |
| 153 | ATOR PX BLOCK ITER | | 1 | 6 | 2 (0)| 00:00:01 | | |
| 154 | STORAGE FULL TABLE ACCESS | WCRS_CURRENT_CLAIM_RPT_DT | 1 | 6 | 2 (0)| 00:00:01 | | |
| 155 | PX BLOCK ITERATOR | | 9699K| 305M| 22192 (1)| 00:00:01 | KEY | KEY |
|*156 | E FULL TABLE ACCESS STORAG | WCRS_CURRENT_CLAIM_FACT | 9699K| 305M| 22192 (1)| 00:00:01 | KEY | KEY |
|*157 | VIEW | | 10M| 555M| 3439 (2)| 00:00:01 | | |
| 158 | PX BLOCK ITERATOR | | 10M| 317M| 3439 (2)| 00:00:01 | | |
| 159 | TABLE ACCESS STORAGE FULL | SYS_TEMP_0FD9D677A_286AAA2E | 10M| 317M| 3439 (2)| 00:00:01 | | |
| 160 | PX BLOCK ITERATOR | | 15M| 599M| 7994 (1)| 00:00:01 | | |
| 161 | TABLE ACCESS STORAGE FULL | INVC_CLAIM_DTL_BRDG_FACT | 15M| 599M| 7994 (1)| 00:00:01 | | |
| 162 | PX BLOCK ITERATOR | | 15M| 641M| 32477 (2)| 00:00:02 | | |
|*163 | TABLE ACCESS STORAGE FULL | INVC_DIM | 15M| 641M| 32477 (2)| 00:00:02 | | |
| 164 | PX RECEIVE | | 15M| 509M| 7994 (1)| 00:00:01 | | |
| 165 | PX SEND HASH | :TQ40010 | 15M| 509M| 7994 (1)| 00:00:01 | | |
| 166 | PX BLOCK ITERATOR | | 15M| 509M| 7994 (1)| 00:00:01 | | |
| 167 | TABLE ACCESS STORAGE FULL | INVC_CLAIM_DTL_BRDG_FACT | 15M| 509M| 7994 (1)| 00:00:01 | | |
| 168 | PX RECEIVE | | 15M| 404M| 7994 (1)| 00:00:01 | | |
| 169 | PX SEND HASH | :TQ40012 | 15M| 404M| 7994 (1)| 00:00:01 | | |
| 170 | PX BLOCK ITERATOR | | 15M| 404M| 7994 (1)| 00:00:01 | | |
| 171 | TABLE ACCESS STORAGE FULL | INVC_CLAIM_DTL_BRDG_FACT | 15M| 404M| 7994 (1)| 00:00:01 | | |
| 172 | TABLE ACCESS BY INDEX ROWID | INVC_ACTY_SNPSHT_FACT | 1 | 58 | 18 (0)| 00:00:01 | | |
|*173 | INDEX RANGE SCAN | IFK_XPKINVOICE_ACTIVITY_SNAPSH | 1 | | 1 (0)| 00:00:01 | | |
| 174 | TABLE ACCESS BY INDEX ROWID | PROVIDER_NETWORK_DIM | 1 | 26 | 0 (0)| 00:00:01 | | |
|*175 | INDEX UNIQUE SCAN | IFK_XPKPROVIDER_NETWORK_DIM | 1 | | 0 (0)| 00:00:01 | | |
|*176 | INDEX RANGE SCAN | IFK_XPKALL_INVC_SNPSHT_FACT | 1 | 18 | 1 (0)| 00:00:01 | | |
| 177 | PX RECEIVE | | 15M| 254M| 7994 (1)| 00:00:01 | | |
| 178 | PX SEND HASH | :TQ40014 | 15M| 254M| 7994 (1)| 00:00:01 | | |
| 179 | PX BLOCK ITERATOR | | 15M| 254M| 7994 (1)| 00:00:01 | | |
| 180 | TABLE ACCESS STORAGE FULL | INVC_CLAIM_DTL_BRDG_FACT | 15M| 254M| 7994 (1)| 00:00:01 | | |
--------------------------------------------------------------------------------------------------------------------------------------------------------------- -
Noob in SQL Tuning seeking help
I am trying to learn SQL Tuning and the workings of it. I know the first step is probably explain execution plan of the sql statement? My problem is I do not understand what am I suppose to gather from the execution plan.
SQL> set autotrace traceonly explain
SQL> select * from employees A
where A.last_employed =
( SELECT TO_CHAR(MAX(TO_DATE(PAY_DATE,'MMRR')),'MMYY')
FROM PAYROLL_VW1 B
WHERE B.SSN = A.SSN AND B.PAY_TYPE_CODE IN ('02','12','22','32')
AND STATUS = 'ACTIVE' AND A.BRANCH=B.BRANCH
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=47427 Card=1 Bytes
=180)
1 0 FILTER
2 1 TABLE ACCESS (FULL) OF 'EMPLOYEES' (TABLE) (Cost=1618 Card
=297964 Bytes=53633520)
3 1 SORT (AGGREGATE)
4 3 VIEW OF 'PAYROLL_VW1' (VIEW) (Cost=2290 Card=2 Bytes=
46)
5 4 SORT (UNIQUE) (Cost=2290 Card=2 Bytes=217)
6 5 UNION-ALL
7 6 FILTER
8 7 TABLE ACCESS (FULL) OF 'PAYROLL2012' (TABLE) (C
ost=2284 Card=1 Bytes=105)
9 6 FILTER
10 9 TABLE ACCESS (BY INDEX ROWID) OF 'PAYROLL2011'
(TABLE) (Cost=4 Card=1 Bytes=112)
11 10 INDEX (RANGE SCAN) OF 'PAYROLL2011_IDX1' (IND
EX) (Cost=3 Card=29)So what do I do with the execution plan? What else do I need to check on it? How do I tune the query?
Edited by: apex_disco on May 1, 2012 5:57 AMI'm not sure how the licensing works. There is a difference between EM and Grid Control. I believe if you just have a single instance, Enterprise Manager is installed and if anything is free I would think that would be. Now, how much of the diagnostic stuff is free? Who knows.
But it may not matter. If you are just playing around "trying to learn SQL Tuning" say, at home on a Linux box, you can install anything you want and play with it.
If adding an index sped things up (in your re-written query that now makes sense) then you must have had a fair amount of records in one of those unindexed tables. If you look at the explain plan now it'll probably show the indexes being used, less records searched, less cost, etc. than the other plan.
But maybe I missed your initial point. Are you trying to learn how to tune queries in general or are you trying to tune this particular query? I assumed the former for my previous replies.
As to your results, your stats </font>tell at least the high level info. The consistent gets and physical reads went WAY down.
Initial Statistics
0 recursive calls
0 db block gets
<font color="red"> 1172490142 consistent gets
4914 physical reads
191496 redo size</font>
2340 bytes sent via SQL*Net to client
329 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
<font color="red">115881 sorts (memory) </font>
0 sorts (disk)
0 rows processed
on those tables and below are my stats now. I think it's a major improvement. Time elapsed has greatly been reduced to 00:00:00.65
Tuned Statistics
352 recursive calls
0 db block gets
<font color="red">31498 consistent gets
1101 physical reads
0 redo size
</font>
2340 bytes sent via SQL*Net to client
329 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
<font color="red">13 sorts (memory) </font>
0 sorts (disk)
0 rows processed
Edited by: Gaff on May 1, 2012 1:18 PM -
Sql Tuning advisor Misc message
HI I am using SQL Tuning advisor to tune one of my queries.I am gettin following recommendation
Miscellaneous The optimizer could not merge the view at line ID 4 of the execution plan.
I am attaching my execution plan .Please let me know what does that mean and what action i have to take
Execution Plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Tim
| 0 | SELECT STATEMENT | | | | 10130 (100)|
| 1 | HASH GROUP BY | | 56 | 15848 | 10130 (1)| 00:
| 2 | VIEW | | 56 | 15848 | 10129 (1)| 00:
| 3 | WINDOW BUFFER | | 56 | 63280 | 10129 (1)| 00:
| 4 | VIEW | | 56 | 63280 | 10129 (1)| 00:
| 5 | WINDOW SORT | | 56 | 24752 | 10129 (1)| 00:
| 6 | NESTED LOOPS | | 56 | 24752 | 10128 (1)| 00:
| 7 | NESTED LOOPS | | 55 | 22165 | 10018 (1)| 00:
| 8 | NESTED LOOPS | | 58 | 21866 | 9902 (1)| 00:
| 9 | NESTED LOOPS | | 60 | 21060 | 9781 (1)| 00:
| 10 | NESTED LOOPS | | 60 | 19020 | 9661 (1)| 00:
| 11 | NESTED LOOPS | | 63 | 18333 | 9534 (1)| 00:
| 12 | NESTED LOOPS | | 67 | 17755 | 9400 (1)| 00:
| 13 | NESTED LOOPS | | 67 | 12931 | 9333 (1)| 00:
| 14 | NESTED LOOPS | | 67 | 11725 | 9266 (1)| 00:
| 15 | HASH JOIN | | 67 | 10854 | 9198 (1)| 00:
| 16 | HASH JOIN | | 67 | 10117 | 9160 (1)| 00:
| 17 | HASH JOIN | | 67 | 9581 | 9154 (1)| 00:
| 18 | TABLE ACCESS BY INDEX ROWID | T_FACT_AGGR_TAX_RPTG | 1355 | 178K| 9149 (1)| 00:
| 19 | NESTED LOOPS | | 67 | 9045 | 9149 (1)| 00:
| 20 | MAT_VIEW ACCESS FULL | MV_T_DIM_INSTM | 1 | 43 | 53 (4)| 00:
| 21 | BITMAP CONVERSION TO ROWIDS| | | | |
| 22 | BITMAP INDEX SINGLE VALUE | XB_T_FACT_AGGR_TAX_RPTG_N5 | | | |
| 23 | MAT_VIEW ACCESS FULL | MV_T_DIM_CURR | 457 | 3656 | 5 (0)| 00:
| 24 | MAT_VIEW ACCESS FULL | MV_T_DIM_CURR | 457 | 3656 | 5 (0)| 00:
| 25 | VIEW | index$_join$_007 | 3480 | 38280 | 38 (6)| 00:
| 26 | HASH JOIN | | | | |
| 27 | INDEX FAST FULL SCAN | XPK_MV_ORIG_T_DIM_MNGMT_ENT | 3480 | 38280 | 10 (0)| 00:
| 28 | INDEX FAST FULL SCAN | X_MV_CUR_T_DIM_MNGMT_ENT_N1 | 3480 | 38280 | 27 (4)| 00:
| 29 | TABLE ACCESS BY INDEX ROWID | T_DIM_DATE | 1 | 13 | 1 (0)| 00:
| 30 | INDEX UNIQUE SCAN | XPK_T_DIM_DATE | 1 | | 0 (0)|
| 31 | MAT_VIEW ACCESS BY INDEX ROWID | MV_T_DIM_EXTL_PARTY | 1 | 18 | 1 (0)| 00:
| 32 | INDEX UNIQUE SCAN | XPK_MV_T_DIM_EXTL_PARTY | 1 | | 0 (0)|
| 33 | MAT_VIEW ACCESS BY INDEX ROWID | MV_T_DIM_LGL_ENT_BR | 1 | 72 | 1 (0)| 00:
| 34 | INDEX UNIQUE SCAN | XPK_MV_O_LGL_ENT_BR | 1 | | 0 (0)|
| 35 | TABLE ACCESS BY INDEX ROWID | T_FACT_DAILY_RATE | 1 | 330 | 2 (0)| 00:
| 36 | INDEX UNIQUE SCAN | XPK_T_FACT_DAILY_RATE | 1 | | 1 (0)| 00:
| 37 | TABLE ACCESS BY INDEX ROWID | T_FACT_DAILY_RATE | 1 | 356 | 2 (0)| 00:
| 38 | INDEX UNIQUE SCAN | XPK_T_FACT_DAILY_RATE | 1 | | 1 (0)| 00:
| 39 | MAT_VIEW ACCESS BY INDEX ROWID | MV_T_DIM_TRD | 1 | 34 | 2 (0)| 00:
| 40 | INDEX UNIQUE SCAN | XPK_MV_T_DIM_TRD | 1 | | 1 (0)| 00:
| 41 | TABLE ACCESS BY INDEX ROWID | T_FACT_DAILY_RATE | 1 | 382 | 2 (0)| 00:
| 42 | INDEX UNIQUE SCAN | XPK_T_FACT_DAILY_RATE | 1 | | 1 (0)| 00:
| 43 | TABLE ACCESS BY INDEX ROWID | T_FACT_DAILY_RATE | 1 | 442 | 2 (0)| 00:
| 44 | INDEX UNIQUE SCAN | XPK_T_FACT_DAILY_RATE | 1 | | 1 (0)| 00:
| 45 | TABLE ACCESS BY INDEX ROWID | T_FACT_AGGR_WGT_AVG_RATE | 1 | 39 | 2 (0)| 00:
| 46 | INDEX UNIQUE SCAN | XPK_T_FACT_AGGR_WGT_AVG_RATE | 1 | | 1 (0)| 00:
Thanks
Pramod GarreNo version number? Why? And I am not interested in manually formatting your post to make it readable.
In the FAQ which you should have read there is a clear explanation of how to use tags so that what you copy in retains its formatting.
Please read the FAQ and correct what you posted as well as providing more information such as the type of application, the DML being executed, and why you are using the tuning advisor at all?
There doesn't seem to be much here that couldn't be far more easily created with:
explain plan for
<your SQL statement>
followed by:
SELECT * FROM TABLE(dbms_xplan.display); -
Dear all,
DB : 10.2.0.4.
Solaris 5.10
One of the monthly process had a problem and one of the select statements was taking a lot of time and when I ran sql tuning advisor, initially it advised me to accept the new sql profile. then since there is no improvements, I proceeded with running sql tuning advisor again which resulted in
Optimizer statistics for index "USER"."CDR_BITMAP_IDX" are stale. Consider collecting optimizer statistics for this index. The optimizer requires up-to-date statistics for the index in order to select a good execution plan.
Miscellaneous SQL Profile "SYS_SQLPROF_02492cc266e98000" exists for this statement and was ignored during the tuning process.
select b.custno ,b.contrno ,b.rowid ,a.subscr_type ,a.area ,a.subno ,
nvl(a.imsi_no,:"SYS_B_00") ,a.extn ,a.b_subno ,a.chargetype ,a.tariffclass ,
a.cdrcode ,to_char(a.transdate,'YYYYMMDD') ,to_char(nvl(a.transdate_to,
a.transdate),'YYYYMMDD') ,nvl(a.no_of_calls,:"SYS_B_01") ,nvl(a.duration,
:"SYS_B_02") ,nvl(a.act_duration,:"SYS_B_03") ,a. time ,a.time_data ,
a.act_time ,a.cdrtext ,a.ar_cdrtext ,a.cdramount ,a.cdramount_int ,
a.gross_amount ,a.gross_amount_int ,nvl(adv_cdramount,:"SYS_B_04") ,
nvl(adv_gross_amount,:"SYS_B_05") ,to_char(nvl(adv_transdate,transdate),
'YYYYMMDD') ,to_char(nvl(adv_transdate_to,transdate_to),'YYYYMMDD') ,
a.factor ,a.factor_int ,to_char(a.upddate,'YYYYMMDD') ,a.tax_class ,
a.vol_group ,nvl(a.table_gen,:"SYS_B_06") ,a.call_type ,
to_char(a.ltd,'YYYYMMDD') ,nvl(a.equipgroup,:"SYS_B_07") ,
nvl(a.equipid,:"SYS_B_08") ,dest_code ,rate_type ,org_tariff_group ,
tariff_group ,rate_pos ,nvl(a.tariff_profile,:"SYS_B_09") ,a.rowid ,
nvl(a.adv_cdred,:"SYS_B_10") ,a.SPLIT_TARIFFCLASS ,a.SPLIT_DURATION ,
a.SPLIT_cdrAMOUNT ,a.SPLIT_cdrAMOUNT_INT
from
cdr_master a ,cdr_control b where (((((b.ltd=to_date(:b0,
:"SYS_B_11") and a.contrno=b.contrno) and b.run_group=:b1) and b.cdr_flag=
:"SYS_B_12") and nvl(a.cdred,:"SYS_B_13")<>:"SYS_B_14") and
(((trunc(a.transdate)<=to_date(:b0,:"SYS_B_15") or ((trunc(a.upddate)<=
to_date(:b0,:"SYS_B_16") and chargetype=:"SYS_B_17") and (((a.cdred is
not null and a.cdred=:"SYS_B_18") and nvl(adv_cdred,:"SYS_B_19")=
:"SYS_B_20") or (((a.cdred is not null and a.cdred=:"SYS_B_21") and
nvl(adv_cdred,:"SYS_B_22")=:"SYS_B_23") and adv_transdate_to<=to_date(:b0,
:"SYS_B_24"))))) or ((a.cdred is not null and a.cdred=:"SYS_B_25") and
nvl(adv_cdred,:"SYS_B_26")=:"SYS_B_27")) or (((a.cdred is not null and
a.cdred=:"SYS_B_28") and nvl(adv_cdred,:"SYS_B_29")=:"SYS_B_30") and
adv_transdate_to<=to_date(:b0,:"SYS_B_31")))) order by a.contrno,a.subno,
a.subscr_type,a.area,nvl(a.equipgroup,:"SYS_B_32"),a.chargetype,a.cdrcode
for update of a.cdred nowait
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 5 451.99 1997.19 596620 37306277 3351623 0
Fetch 404 0.96 0.84 0 0 0 39900
total 409 452.95 1998.04 596620 37306277 3351623 39900
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 185
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 404 0.00 0.00
SQL*Net more data to client 3219 0.00 0.03
SQL*Net message from client 404 0.00 0.22
gc current block 2-way 34454 0.27 21.77
gc cr multi block request 2649 0.27 1.06
db file sequential read 596211 0.15 1561.81
gc cr block busy 16 0.00 0.02
db file parallel read 11 0.00 0.04
db file scattered read 50 0.01 0.10
gc cr block 2-way 2 0.00 0.00
gc current grant 2-way 6 0.00 0.00
latch: cache buffers chains 9 0.00 0.00
gc current block congested 6 0.00 0.02
gc current grant busy 257 0.00 0.17
latch: object queue header operation 3 0.00 0.00
log file switch completion 22 0.82 2.52
latch free 27 0.00 0.00
log buffer space 7 0.24 0.83
log file switch (checkpoint incomplete) 10 0.98 1.47
gc cr grant 2-way 2 0.00 0.00Any idea what am missing ?
KaiHi,
Try to Update the Stats of the Source tables and re-reun the Advisor, that might give or suggest different things further.
Second thing, check that Referred SQL profile and I would suggest if it not used, then drop that and check.
Surprised to see huge wait event on "db file sequential read"
- Pavan Kumar N -
I wanted to use the SQL Tuning Advisor feature of the SQL Worksheet. The DBA granted me ADVISOR system privilege. But when I tried to use the feature, I get the following errors:
An error was encountered performing the requested operation:
ORA-06550: line 20, column 101:
PLS-00103: Encountered the symbol "ANYDATA" when expecting one of the folllowing:
.(),*%&=-+</> at in is mod remainder not rem
<an exponenet (**) <> or != or ~= >= <> and or like LIKE2_
LIKE4_LIKEC_between|| multiset member SUBMULTISET_
The symbol "." was substituted for "ANYDATA" to continue.
ORA-6550: line 20, column 140:
PLS-00103: Encountered the symbol "ANYDATA" when expecting one of the folllowing:
.(),*%&=-+</> at in is mod remainder not rem
<an exponenet (**) <> or != or ~= >= <> and or like LIKE2_
LIKE4_LIKEC_between|| mul
ORA-6550:line 20, column 179:
PLS-00103: Encountered the symbol "ANYDATA" when expecting one of the folllowing:
.(),*%&=-+</> at in is mod remainder not rem
<an exponenet (**) <> or != or ~= >= <> and or like LIKE2_
LIKE4_LIKEC_between|| multiset
06550,00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Vendor code 6550Then I get this right after the previous one:
An error was encountered performing the requested operation:
ORA-13605: The specified task or boject staName12325 does not exist for the current user.
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.PRVT_ADVISOR", line 4841
ORA-06512: at "SYS.DBMS_SQLTUNE", line 1093
ORA-06512: at line 2
13605.0000 - "The specified task or object %s does not exist for the current user."
*Cause: The user attempted to reference an advisor task or object
using a anme that does not exist in the Advisor repository.
*Action: Adjust the name and retry the operation.
Vendor code 13605Can someone please help me? I am not a DBA so I stumped by these error codes.
Oracle SQL Developer 3.0.04 Build MAIn-04.34
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0
RobertThe query is
select "V_CDR_OUTGOING_CALLS"."FIRST_NAME" as "FIRST_NAME",
"V_CDR_OUTGOING_CALLS"."MIDDLE_INITIAL" as "MIDDLE_INITIAL",
"V_CDR_OUTGOING_CALLS"."LAST_NAME" as "LAST_NAME",
"V_CDR_OUTGOING_CALLS"."ORG_UNIT" as "ORG_UNIT",
"V_CDR_OUTGOING_CALLS"."DEPT_DESC" as "DEPT_DESC",
"V_CDR_OUTGOING_CALLS"."FROM_NUMBER" as "FROM_NUMBER",
"V_CDR_OUTGOING_CALLS"."TO_NUMBER" as "TO_NUMBER",
"V_CDR_OUTGOING_CALLS"."TO_CITY" as "TO_CITY",
"V_CDR_OUTGOING_CALLS"."TO_STATE" as "TO_STATE",
"V_CDR_OUTGOING_CALLS"."DATETIME_CONNECT" as "DATETIME_CONNECT",
"V_CDR_OUTGOING_CALLS"."DURATION_MIN" as "DURATION_MIN"
from "V_CDR_OUTGOING_CALLS" "V_CDR_OUTGOING_CALLS"
where :P12_PHONE_NUMBER = FROM_NUMBER or :P12_PHONE_NUMBER = TO_NUMBER
AND "V_CDR_OUTGOING_CALLS"."DATETIME_CONNECT" BETWEEN to_date(:P12_START_DATE,'MM/DD/YYYY') AND to_date(:P12_END_DATE,'MM/DD/YYYY')The view is
CREATE OR REPLACE FORCE VIEW "VOIP"."V_CDR_OUTGOING_CALLS" ("ID", "EMPID", "FIRST_NAME", "MIDDLE_INITIAL", "LAST_NAME", "ORG_UNIT", "DEPT_DESC", "PHONE", "FROM_NUMBER", "TO_NUMBER", "TO_CITY", "TO_STATE", "DATETIME_CONNECT", "DATETIME_DISCONNECT", "DURATION_SEC", "DURATION_MIN")
AS
SELECT c.ID,
e.empid empid,
e.first_name,
e.middle_initial,
e.last_name,
e.org_descr,
e.dept_desc,
e.full_telephone,
c.from_number,
c.to_number,
x.city to_city,
x.state to_state,
c.datetime_connect,
c.datetime_disconnect,
c.duration_sec,
c.duration_min
FROM v_cdr c ,
v_cdr_emp e,
telephone_exchanges x
WHERE c.from_number = e.phone
AND SUBSTR(c.to_number,1,7) = x.EXCHANGE
AND LENGTH(c.to_number) > 7;The table and views are defined as:
CREATE TABLE "VOIP"."TELEPHONE_EXCHANGES"
"EXCHANGE" VARCHAR2(7 BYTE) NOT NULL ENABLE,
"CITY" VARCHAR2(200 BYTE),
"STATE" VARCHAR2(2 BYTE),
CONSTRAINT "TELEPHONE_EXCHANGES_PK" PRIMARY KEY ("EXCHANGE") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "VOIPDATA" ENABLE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "VOIPDATA" ;
CREATE OR REPLACE FORCE VIEW "VOIP"."V_CDR" ("ID", "FROM_NUMBER", "TO_NUMBER", "DATETIME_CONNECT", "DATETIME_DISCONNECT", "DURATION_SEC", "DURATION_MIN", "PKID", "DATE_OF_CALL")
AS
SELECT ID,
DECODE( LENGTH(CALLINGPARTYNUMBER),6, SUBSTR(CALLINGPARTYNUMBER,1,2)
|| '-'
||SUBSTR(CALLINGPARTYNUMBER,3) ,10, SUBSTR(CALLINGPARTYNUMBER,1,3)
|| '-'
||SUBSTR(CALLINGPARTYNUMBER,4,3)
|| '-'
||SUBSTR(CALLINGPARTYNUMBER,7) ,CALLINGPARTYNUMBER)FROM_NUMBER,
DECODE( LENGTH(ORIGINALCALLEDPARTYNUMBER), 6, SUBSTR( ORIGINALCALLEDPARTYNUMBER,1,2)
|| '-'
||SUBSTR(ORIGINALCALLEDPARTYNUMBER,3) , 10, SUBSTR( ORIGINALCALLEDPARTYNUMBER,1,3)
|| '-'
||SUBSTR(ORIGINALCALLEDPARTYNUMBER,4,3)
|| '-'
||SUBSTR(ORIGINALCALLEDPARTYNUMBER,7) , 12, SUBSTR( ORIGINALCALLEDPARTYNUMBER,3,3)
|| '-'
||SUBSTR(ORIGINALCALLEDPARTYNUMBER,6,3)
|| '-'
||SUBSTR(ORIGINALCALLEDPARTYNUMBER,9) , ORIGINALCALLEDPARTYNUMBER) TO_NUMBER,
new_time(to_date(TO_CHAR(to_date('01.01.70','dd.mm.rr')+ (DATETIMECONNECT/( 60 *60*24)), 'mm-dd-yyyy hh24:mi:ss'),'mm-dd-yyyy hh24:mi:ss'),'GMT','EDT') DATETIME_CONNECT,
new_time(to_date(TO_CHAR(to_date('01.01.70','dd.mm.rr')+ ( DATETIMEDISCONNECT /(60*60*24)), 'mm-dd-yyyy hh24:mi:ss'),'mm-dd-yyyy hh24:mi:ss'),'GMT','EDT') DATETIME_DISCONNECT,
duration Duration_sec,
ROUND(duration/60,2) Duration_MIN,
pkid,
to_date(TO_CHAR(new_time(to_date(TO_CHAR(to_date('01.01.70','dd.mm.rr')+ (DATETIMECONNECT/( 60 *60*24)), 'mm-dd-yyyy hh24:mi:ss'),'mm-dd-yyyy hh24:mi:ss'),'GMT','EDT'),'DD-MON-YYYY')) date_of_call
FROM CALL_DETAILS_CDR C
WHERE datetimeconnect <> 0;
The above view is based on table CALL_DETAILS_CDR defined as:
CREATE TABLE "VOIP"."CALL_DETAILS_CDR"
"ID" NUMBER NOT NULL ENABLE,
"CDRRECORDTYPE" NUMBER,
"G_CALLMANAGERID" NUMBER,
"G_CALLID" NUMBER,
"O_LEGCALLIDENTIFIER" NUMBER,
"DATETIMEORIGINATION" NUMBER,
"O_NODEID" NUMBER,
"O_SPAN" NUMBER,
"O_IPADDR" NUMBER,
"CALLINGPARTYNUMBER" VARCHAR2(50 BYTE),
"CALLINGPARTY_USERID" VARCHAR2(128 BYTE),
"O_CAUSE_LOCATION" NUMBER,
"O_CAUSE_VALUE" NUMBER,
"O_PRECEDENCELEVEL" NUMBER,
"O_MEDIATRANSPORTADDR_IP" NUMBER,
"O_MEDIATRANSPORTADDR_PORT" NUMBER,
"O_MCAP_PAYLOADCAPABILITY" NUMBER,
"O_MCAP_MAXFRAMESPERPACKET" NUMBER,
"O_MCAP_G723BITRATE" NUMBER,
"O_VCAP_CODEC" NUMBER,
"O_VCAP_BANDWIDTH" NUMBER,
"O_VCAP_RESOLUTION" NUMBER,
"O_VIDEOTRANSPORTADDR_IP" NUMBER,
"O_VIDEOTRANSPORTADDR_PORT" NUMBER,
"O_RSVPAUDIOSTAT" VARCHAR2(64 BYTE),
"O_RSVPVIDEOSTAT" VARCHAR2(64 BYTE),
"DESTLEGIDENTIFIER" NUMBER,
"DESTNODEID" NUMBER,
"DESTSPAN" NUMBER,
"DESTIPADDR" NUMBER,
"ORIGINALCALLEDPARTYNUMBER" VARCHAR2(50 BYTE),
"FINALC_PARTYNUMBER" VARCHAR2(50 BYTE),
"FINALC_PARTY_USERID" VARCHAR2(128 BYTE),
"DESTCAUSE_LOCATION" NUMBER,
"DESTCAUSE_VALUE" NUMBER,
"DESTPRECEDENCELEVEL" NUMBER,
"DESTMEDIATRANSPORTADDR_IP" NUMBER,
"DESTMEDIATRANSPORTADDR_PORT" NUMBER,
"DESTMCAP_PAYLOADCAPABILITY" NUMBER,
"DESTMCAP_MAXFRAMESPERPACKET" NUMBER,
"DESTMCAP_G723BITRATE" NUMBER,
"DV_CAP_CODEC" NUMBER,
"DV_CAP_BANDWIDTH" NUMBER,
"DV_CAP_RESOLUTION" NUMBER,
"DV_TRANSPORTADDR_IP" NUMBER,
"DV_TRANSPORTADDR_PORT" NUMBER,
"DESTRSVPAUDIOSTAT" VARCHAR2(64 BYTE),
"DESTRSVPVIDEOSTAT" VARCHAR2(64 BYTE),
"DATETIMECONNECT" NUMBER,
"DATETIMEDISCONNECT" NUMBER,
"LASTREDIRECTDN" VARCHAR2(50 BYTE),
"PKID" VARCHAR2(4000 BYTE),
"O_INALCALLEDPARTYNUM_PARTITION" VARCHAR2(50 BYTE),
"CALLINGPARTYNUM_PARTITION" VARCHAR2(50 BYTE),
"FINALC_PARTYNUM_PARTITION" VARCHAR2(50 BYTE),
"LASTREDIRECTDNPARTITION" VARCHAR2(50 BYTE),
"DURATION" NUMBER,
"O_DEVICENAME" VARCHAR2(129 BYTE),
"DESTDEVICENAME" VARCHAR2(129 BYTE),
"O_CALLTERMINATION_BEHALF" NUMBER,
"DESTCALLTERMINATION_BEHALF" NUMBER,
"O_CALLEDPARTYREDIRECT_BEHALF" NUMBER,
"LASTREDIRECTREDIRECT_BEHALF" NUMBER,
"O_CALLEDPARTYREDIRECTREASON" NUMBER,
"LASTREDIRECTREDIRECTREASON" NUMBER,
"DESTCONVERSATIONID" NUMBER,
"G_CALLID_CLUSTERID" VARCHAR2(50 BYTE),
"JOIN_BEHALF" NUMBER,
"COMMENTS" VARCHAR2(2048 BYTE),
"AUTHCODEDESCRIPTION" VARCHAR2(50 BYTE),
"AUTHORIZATIONLEVEL" NUMBER,
"CLIENTMATTERCODE" VARCHAR2(32 BYTE),
"O_DTMFMETHOD" NUMBER,
"DESTDTMFMETHOD" NUMBER,
"CALLSECUREDSTATUS" NUMBER,
"O_CONVERSATIONID" NUMBER,
"O_MCAP_BANDWIDTH" NUMBER,
"DESTMCAP_BANDWIDTH" NUMBER,
"AUTHORIZATIONCODEVALUE" VARCHAR2(32 BYTE),
"OUTPULSEDCALLINGPARTYNUMBER" VARCHAR2(50 BYTE),
"OUTPULSEDCALLEDPARTYNUMBER" VARCHAR2(50 BYTE),
"O_IPV4V6ADDR" VARCHAR2(64 BYTE),
"DESTIPV4V6ADDR" VARCHAR2(64 BYTE),
"O_VCAP_CODEC_CHAN2" NUMBER,
"O_VCAP_BANDWIDTH_CHAN2" NUMBER,
"O_VCAP_RESOLUTION_CHAN2" NUMBER,
"O_V_TRANSPORTADDR_IP_CHAN2" NUMBER,
"O_V_TRANSPORTADDR_PORT_CHAN2" NUMBER,
"O_V_OCHANNEL_ROLE_CHAN2" NUMBER,
"DV_CAP_CODEC_CHAN2" NUMBER,
"DV_CAP_BANDWIDTH_CHAN2" NUMBER,
"DV_CAP_RESOLUTION_CHAN2" NUMBER,
"DV_TRANSPORTADDR_IP_CHAN2" NUMBER,
"DV_TRANSPORTADDR_PORT_CHAN2" NUMBER,
"DV_CHANNEL_ROLE_CHAN2" NUMBER,
"DATE_CREATED" DATE,
CONSTRAINT "CALL_DETAILS_CDR_PK" PRIMARY KEY ("ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "VOIPDATA" ENABLE,
CONSTRAINT "PKID_UNIQUE" UNIQUE ("PKID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 167 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "VOIPDATA" ENABLE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "VOIPDATA" ;
CREATE INDEX "VOIP"."CALL_DETAILS_CDR_INDEX3" ON "VOIP"."CALL_DETAILS_CDR"
"ORIGINALCALLEDPARTYNUMBER",
"DATETIMECONNECT"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "VOIPDATA" ;
CREATE INDEX "VOIP"."CALL_DETAILS_CDR_INDEX2" ON "VOIP"."CALL_DETAILS_CDR"
"CALLINGPARTYNUMBER",
"DATETIMECONNECT"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "VOIPDATA" ;
CREATE UNIQUE INDEX "VOIP"."CALL_DETAILS_CDR_PK" ON "VOIP"."CALL_DETAILS_CDR"
"ID"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "VOIPDATA" ;
CREATE UNIQUE INDEX "VOIP"."PKID_UNIQUE" ON "VOIP"."CALL_DETAILS_CDR"
"PKID"
PCTFREE 10 INITRANS 2 MAXTRANS 167 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "VOIPDATA" ;
The view, V_CDR_EMP, is defined as:
CREATE OR REPLACE FORCE VIEW "VOIP"."V_CDR_EMP" ("EMPID", "FIRST_NAME", "MIDDLE_INITIAL", "LAST_NAME", "ORG", "ORG_DESCR", "DEPT", "DEPT_DESC", "ADDRESS", "PHONE", "FULL_TELEPHONE")
AS
SELECT e.empid,
e.First_name,
e.Middle_Initial,
e.Last_name,
e.Org,
o.org_descr,
e.Dept,
d.Dept_desc,
e.Address,
DECODE (SUBSTR(e.address,1,6),'ONEMAD','10-'
|| SUBSTR (e.telephone,9), '225PAS','10-'
|| SUBSTR (e.telephone,9), '233PAS','10-'
|| SUBSTR (e.telephone,9), '115BWA','10-'
|| SUBSTR (e.telephone,9), DECODE(SUBSTR(e.address,1,4),'PATC','11-'
|| SUBSTR (e.telephone,9), 'JAMS','12-'
|| SUBSTR (e.telephone,9), 'JSTC','12-'
|| SUBSTR (e.telephone,9), 'PABT','19-'
|| SUBSTR (e.telephone,9), 'TLPT','08-'
|| SUBSTR (e.telephone,9), 'HCMF','12-'
|| SUBSTR (e.telephone,9), DECODE(SUBSTR(e.address,1,3),'GWB','17-'
|| SUBSTR (e.telephone,9), 'LGA','13-'
|| SUBSTR (e.telephone,9), 'EWR','14-'
|| SUBSTR (e.telephone,9), 'JFK','15-'
|| SUBSTR (e.telephone,9), 'SIB','18-'
|| SUBSTR (e.telephone,9), 'MVP','14-'
|| SUBSTR (e.telephone,9), 'WTC','10-'
|| SUBSTR (e.telephone,9), 'CON','12-'
|| SUBSTR (e.telephone,9), DECODE(SUBSTR(e.address,1,2),'HT','11-'
|| SUBSTR (e.telephone,9), 'BP','06-'
|| SUBSTR (e.telephone,9), 'LT','16-'
|| SUBSTR (e.telephone,9), 'PN','07-'
|| SUBSTR (e.telephone,9), DECODE(SUBSTR(e.address,1,5),'2GWAY','04-'
|| SUBSTR (e.telephone,9), '3GWAY','04-'
|| SUBSTR (e.telephone,9), DECODE(SUBSTR(e.address,1,10),'PORT IVORY','07-'
|| SUBSTR (e.telephone,9),e.telephone) ) ) ) ) ) phone,
e.telephone full_telephone
FROM [email protected] e ,
[email protected] d ,
[email protected] o
WHERE e.active = 'Y'
AND e.dept = d.dept
AND e.org = o.org;Robert -
A SQL tuning issue-sql runs much slower in test than in production?
Hi Buddies,
I am working on a sql tuning issue. A sql runs much slower in test than in production.
I compared the two explain plans in test and production
seems in test, CBO refuses to use index SUBLEDGER_ENTRY_I2.
we rebuile it and re-gether that index statistcs. run, still slow..
I compared the init.ora parameters like hash_area_size, sort_area_size in test, they are same as production.
I wonder if any expert friend can show some light.
in production,
SQL> set autotrace traceonly
SQL> SELECT rpt_horizon_subledger_entry_vw.onst_offst_cd,
2 rpt_horizon_subledger_entry_vw.bkng_prd,
3 rpt_horizon_subledger_entry_vw.systm_afflt_cd,
4 rpt_horizon_subledger_entry_vw.jrnl_id,
5 rpt_horizon_subledger_entry_vw.ntrl_accnt_cd,
6 rpt_horizon_subledger_entry_vw.gnrl_ldgr_chrt_of_accnt_nm,
7 rpt_horizon_subledger_entry_vw.lgl_entty_brnch_cd,
8 rpt_horizon_subledger_entry_vw.crprt_melob_cd AS corp_mlb_cd,
rpt_horizon_subledger_entry_vw.onst_offst_cd, SUM (amt) AS amount
9 10 FROM rpt_horizon_subledger_entry_vw
11 WHERE rpt_horizon_subledger_entry_vw.bkng_prd = '092008'
12 AND rpt_horizon_subledger_entry_vw.jrnl_id = 'RCS0002100'
13 AND rpt_horizon_subledger_entry_vw.systm_afflt_cd = 'SAFF01'
14 GROUP BY rpt_horizon_subledger_entry_vw.onst_offst_cd,
15 rpt_horizon_subledger_entry_vw.bkng_prd,
16 rpt_horizon_subledger_entry_vw.systm_afflt_cd,
17 rpt_horizon_subledger_entry_vw.jrnl_id,
18 rpt_horizon_subledger_entry_vw.ntrl_accnt_cd,
19 rpt_horizon_subledger_entry_vw.gnrl_ldgr_chrt_of_accnt_nm,
20 rpt_horizon_subledger_entry_vw.lgl_entty_brnch_cd,
21 rpt_horizon_subledger_entry_vw.crprt_melob_cd,
22 rpt_horizon_subledger_entry_vw.onst_offst_cd;
491 rows selected.
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=130605 Card=218764 B
ytes=16407300)
1 0 SORT (GROUP BY) (Cost=130605 Card=218764 Bytes=16407300)
2 1 VIEW OF 'RPT_HORIZON_SUBLEDGER_ENTRY_VW' (Cost=129217 Ca
rd=218764 Bytes=16407300)
3 2 SORT (UNIQUE) (Cost=129217 Card=218764 Bytes=35877296)
4 3 UNION-ALL
5 4 HASH JOIN (Cost=61901 Card=109382 Bytes=17719884)
6 5 TABLE ACCESS (FULL) OF 'GNRL_LDGR_CHRT_OF_ACCNT'
(Cost=2 Card=111 Bytes=3774)
7 5 HASH JOIN (Cost=61897 Card=109382 Bytes=14000896
8 7 TABLE ACCESS (FULL) OF 'SUBLEDGER_CHART_OF_ACC
OUNT' (Cost=2 Card=57 Bytes=1881)
9 7 HASH JOIN (Cost=61893 Card=109382 Bytes=103912
90)
10 9 TABLE ACCESS (FULL) OF 'HORIZON_LINE' (Cost=
34 Card=4282 Bytes=132742)
11 9 HASH JOIN (Cost=61833 Card=109390 Bytes=7000
960)
12 11 TABLE ACCESS (BY INDEX ROWID) OF 'SUBLEDGE
R_ENTRY' (Cost=42958 Card=82076 Bytes=3611344)
13 12 INDEX (RANGE SCAN) OF 'SUBLEDGER_ENTRY_I
2' (NON-UNIQUE) (Cost=1069 Card=328303)
14 11 TABLE ACCESS (FULL) OF 'HORIZON_SUBLEDGER_
LINK' (Cost=14314 Card=9235474 Bytes=184709480)
15 4 HASH JOIN (Cost=61907 Card=109382 Bytes=18157412)
16 15 TABLE ACCESS (FULL) OF 'GNRL_LDGR_CHRT_OF_ACCNT'
(Cost=2 Card=111 Bytes=3774)
17 15 HASH JOIN (Cost=61903 Card=109382 Bytes=14438424
18 17 TABLE ACCESS (FULL) OF 'SUBLEDGER_CHART_OF_ACC
OUNT' (Cost=2 Card=57 Bytes=1881)
19 17 HASH JOIN (Cost=61899 Card=109382 Bytes=108288
18)
20 19 TABLE ACCESS (FULL) OF 'HORIZON_LINE' (Cost=
34 Card=4282 Bytes=132742)
21 19 HASH JOIN (Cost=61838 Card=109390 Bytes=7438
520)
22 21 TABLE ACCESS (BY INDEX ROWID) OF 'SUBLEDGE
R_ENTRY' (Cost=42958 Card=82076 Bytes=3939648)
23 22 INDEX (RANGE SCAN) OF 'SUBLEDGER_ENTRY_I
2' (NON-UNIQUE) (Cost=1069 Card=328303)
24 21 TABLE ACCESS (FULL) OF 'HORIZON_SUBLEDGER_
LINK' (Cost=14314 Card=9235474 Bytes=184709480)
Statistics
25 recursive calls
18 db block gets
343266 consistent gets
370353 physical reads
0 redo size
15051 bytes sent via SQL*Net to client
1007 bytes received via SQL*Net from client
34 SQL*Net roundtrips to/from client
1 sorts (memory)
1 sorts (disk)
491 rows processed
in test
SQL> set autotrace traceonly
SQL> SELECT rpt_horizon_subledger_entry_vw.onst_offst_cd,
2 rpt_horizon_subledger_entry_vw.bkng_prd,
3 rpt_horizon_subledger_entry_vw.systm_afflt_cd,
4 rpt_horizon_subledger_entry_vw.jrnl_id,
5 rpt_horizon_subledger_entry_vw.ntrl_accnt_cd,
rpt_horizon_subledger_entry_vw.gnrl_ldgr_chrt_of_accnt_nm,
6 7 rpt_horizon_subledger_entry_vw.lgl_entty_brnch_cd,
8 rpt_horizon_subledger_entry_vw.crprt_melob_cd AS corp_mlb_cd,
9 rpt_horizon_subledger_entry_vw.onst_offst_cd, SUM (amt) AS amount
10 FROM rpt_horizon_subledger_entry_vw
11 WHERE rpt_horizon_subledger_entry_vw.bkng_prd = '092008'
12 AND rpt_horizon_subledger_entry_vw.jrnl_id = 'RCS0002100'
AND rpt_horizon_subledger_entry_vw.systm_afflt_cd = 'SAFF01'
13 14 GROUP BY rpt_horizon_subledger_entry_vw.onst_offst_cd,
15 rpt_horizon_subledger_entry_vw.bkng_prd,
16 rpt_horizon_subledger_entry_vw.systm_afflt_cd,
17 rpt_horizon_subledger_entry_vw.jrnl_id,
18 rpt_horizon_subledger_entry_vw.ntrl_accnt_cd,
rpt_horizon_subledger_entry_vw.gnrl_ldgr_chrt_of_accnt_nm,
rpt_horizon_subledger_entry_vw.lgl_entty_brnch_cd,
rpt_horizon_subledger_entry_vw.crprt_melob_cd,
rpt_horizon_subledger_entry_vw.onst_offst_cd; 19 20 21 22
no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=92944 Card=708 Bytes
=53100)
1 0 SORT (GROUP BY) (Cost=92944 Card=708 Bytes=53100)
2 1 VIEW OF 'RPT_HORIZON_SUBLEDGER_ENTRY_VW' (Cost=92937 Car
d=708 Bytes=53100)
3 2 SORT (UNIQUE) (Cost=92937 Card=708 Bytes=124962)
4 3 UNION-ALL
5 4 HASH JOIN (Cost=46456 Card=354 Bytes=60180)
6 5 TABLE ACCESS (FULL) OF 'SUBLEDGER_CHART_OF_ACCOU
NT' (Cost=2 Card=57 Bytes=1881)
7 5 NESTED LOOPS (Cost=46453 Card=354 Bytes=48498)
8 7 HASH JOIN (Cost=11065 Card=17694 Bytes=1362438
9 8 HASH JOIN (Cost=27 Card=87 Bytes=5133)
10 9 TABLE ACCESS (FULL) OF 'HORIZON_LINE' (Cos
t=24 Card=87 Bytes=2175)
11 9 TABLE ACCESS (FULL) OF 'GNRL_LDGR_CHRT_OF_
ACCNT' (Cost=2 Card=111 Bytes=3774)
12 8 TABLE ACCESS (FULL) OF 'HORIZON_SUBLEDGER_LI
NK' (Cost=11037 Card=142561 Bytes=2566098)
13 7 TABLE ACCESS (BY INDEX ROWID) OF 'SUBLEDGER_EN
TRY' (Cost=2 Card=1 Bytes=60)
14 13 INDEX (UNIQUE SCAN) OF 'SUBLEDGER_ENTRY_PK'
(UNIQUE) (Cost=1 Card=1)
15 4 HASH JOIN (Cost=46456 Card=354 Bytes=64782)
16 15 TABLE ACCESS (FULL) OF 'SUBLEDGER_CHART_OF_ACCOU
NT' (Cost=2 Card=57 Bytes=1881)
17 15 NESTED LOOPS (Cost=46453 Card=354 Bytes=53100)
18 17 HASH JOIN (Cost=11065 Card=17694 Bytes=1362438
19 18 HASH JOIN (Cost=27 Card=87 Bytes=5133)
20 19 TABLE ACCESS (FULL) OF 'HORIZON_LINE' (Cos
t=24 Card=87 Bytes=2175)
21 19 TABLE ACCESS (FULL) OF 'GNRL_LDGR_CHRT_OF_
ACCNT' (Cost=2 Card=111 Bytes=3774)
22 18 TABLE ACCESS (FULL) OF 'HORIZON_SUBLEDGER_LI
NK' (Cost=11037 Card=142561 Bytes=2566098)
23 17 TABLE ACCESS (BY INDEX ROWID) OF 'SUBLEDGER_EN
TRY' (Cost=2 Card=1 Bytes=73)
24 23 INDEX (UNIQUE SCAN) OF 'SUBLEDGER_ENTRY_PK'
(UNIQUE) (Cost=1 Card=1)
Statistics
1134 recursive calls
0 db block gets
38903505 consistent gets
598254 physical reads
60 redo size
901 bytes sent via SQL*Net to client
461 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
34 sorts (memory)
0 sorts (disk)
0 rows processed
Thanks a lot in advance
JerryHi
Basically there are two kinds of tables
- fact
- lookup
The number of records in a lookup table is usually small.
The number of records in a fact table is usually huge.
However, in test systems the number of records in a fact table is often also small.
This results in different execution plans.
I notice again you don't post version and platform info, and you didn't make sure your explain is properly idented
Please read the FAQ to make sure it is properly idented.
Also using the word 'buddies' is as far as I am concerned nearing disrespect and rudeness.
Sybrand Bakker
Senior Oracle DBA -
Need help to debug SQL Tuning Advisor Error Message
Hi,
I am getting an error message while try to get recommendations from the SQL Tuning Advisor.
Environment:
Oracle Version: 11.2.0.3.0
O/S: AIX
Following is my code:
declare
my_task_name varchar2 (30);
my_sqltext clob;
begin
my_sqltext := 'SELECT DISTINCT MRKT_AREA AS DIVISION, PROMO_ID,
PROMO_CODE,
RBR_DTL_TYPE.PERF_DETL_TYP,
RBR_DTL_TYPE.PERF_DETL_DESC,
RBR_DTL_TYPE.PERF_DETL_SUB_TYP,
RBR_DTL_TYPE.PERF_DETL_SUB_DESC,
BU_SYS_ITM_NUM,
RBR_CPN_LOC_ITEM_ARCHIVE.CLI_SYS_ITM_DESC,
PROMO_START_DATE,
PROMO_END_DATE,
PROMO_VALUE2,
PROMO_VALUE1,
EXEC_COMMENTS,
PAGE_NUM,
BLOCK_NUM,
AD_PLACEMENT,
BUYER_CODE,
RBR_CPN_LOC_ITEM_ARCHIVE.CLI_STAT_TYP,
RBR_MASTER_CAL_ARCHIVE.STATUS_FLAG
FROM (PROMO_REPT_OWNER.RBR_CPN_LOC_ITEM_ARCHIVE
INNER JOIN PROMO_REPT_OWNER.RBR_MASTER_CAL_ARCHIVE
ON (RBR_CPN_LOC_ITEM_ARCHIVE.CLI_PROMO_ID = PROMO_ID)
AND (RBR_CPN_LOC_ITEM_ARCHIVE.CLI_PERF_DTL_ID = PERF_DETAIL_ID)
AND (RBR_CPN_LOC_ITEM_ARCHIVE.CLI_STR_NBR = STORE_ZONE)
AND (RBR_CPN_LOC_ITEM_ARCHIVE.CLI_ITM_ID = ITM_ID))
INNER JOIN PROMO_REPT_OWNER.RBR_DTL_TYPE
ON (RBR_MASTER_CAL_ARCHIVE.PERF_DETL_TYP = RBR_DTL_TYPE.PERF_DETL_TYP)
AND (RBR_MASTER_CAL_ARCHIVE.PERF_DETL_SUB_TYP = RBR_DTL_TYPE.PERF_DETL_SUB_TYP)
WHERE ( ((MRKT_AREA)=40)
AND ((RBR_DTL_TYPE.PERF_DETL_TYP)=1)
AND ((RBR_DTL_TYPE.PERF_DETL_SUB_TYP)=1) )
AND ((CLI_STAT_TYP)=1 Or (CLI_STAT_TYP)=6)
AND ((RBR_MASTER_CAL_ARCHIVE.STATUS_FLAG)=''A'')
AND ( ((PROMO_START_DATE) >= to_date(''2011-10-20'', ''YYYY-MM-DD'')
And (PROMO_END_DATE) <= to_date(''2011-10-26'', ''YYYY-MM-DD'')) )
ORDER BY MRKT_AREA';
my_task_name := dbms_sqltune.create_tuning_task
(sql_text => my_sqltext,
user_name => 'PROMO_REPT_OWNER',
scope => 'COMPREHENSIVE',
time_limit => 3600,
task_name => 'Test_Query',
description => 'Test Query');
end;
begin
dbms_sqltune.execute_tuning_task(task_name => 'Test_Query');
end;
set serveroutput on size unlimited;
set pagesize 5000
set linesize 130
set long 50000
set longchunksize 500000
SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK('Test_Query') FROM DUAL;
Output:
snippet .....
FINDINGS SECTION (1 finding)
1- Index Finding (see explain plans section below)
The execution plan of this statement can be improved by creating one or more
indices.
Recommendation (estimated benefit: 71.48%)
- Consider running the Access Advisor to improve the physical schema design
or creating the recommended index.
Error: Cannot fetch actions for recommendation: INDEX
Error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Rationale
Creating the recommended indices significantly improves the execution plan
of this statement. However, it might be preferable to run "Access Advisor"
using a representative SQL workload as opposed to a single statement. This
will allow to get comprehensive index recommendations which takes into
account index maintenance overhead and additional space consumption.
snippet
Any ideas why I am getting ORA-06502 error?
Thanks in advance
RogersBug 14407401 - ORA-6502 from index recommendation section of DBMS_SQLTUNE output (Doc ID 14407401.8)
Fixed:
The fix for 14407401 is first included in
12.1.0.1 (Base Release) -
Hi,
I would like to know any SQL tuning methods specific to Oracle exadata so that they could improve the performance of the database?
I am aware that oracle exadata runs with Oracle 11g, but i would like to know wheather there is any tuning scope w.r.t to SQL's on exadata?
regards
sunilWell there are some things that are very different about Exadata. All the standard Oracle SQL tuning you have learned already should not be forgotten as Exadata is running standard 11g database code, but there are many optimizations that have been added that you should be aware of. At a high level, if you are doing OLTP type work you should be trying to make sure that you take advantage of Exadata Smart Flash Cache which will significantly speed up your small I/O's. But long running queries are where the big benefits show up. The high level tuning approach for them is as follows:
1. Check to see if you are getting Smart Scans.
2. If you aren't, fix what ever is preventing them from being used.
We've been involved in somewhere between 25-30 DB Machine installations now and in many cases, a little bit of effort changes performance dramatically. If you are only getting 2 to 3X improvement over your previous platform on these long running queries you are probably not getting the full benefit of the Exadata optimizations. So the first step is learning how to determine if you are getting Smart Scans or not and on what portions of the statement. Wait events, session statistics, V$SQL, SQL Monitoring are all viable tools that can show you that information. -
Permissions needed for Applying SQL Tuning Sets/SQL Plans 11g?
What permission are needed for a user to apply/activate sql tuning sets (sql plans) in 11g? The user can capture and move the the sql tuning sets from a 10g database to an 11g database but is getting "ORA-01031: insufficient privileges" when trying to activate/apply the sqlplans in 11g.
The user has:
ADMINISTER SQL MANAGEMENT OBJECT and ADMINISTER SQL TUNING SET and EXECUTE on SYS.DBMS_SPM
The user is an administrator for our Data Warehouse team but they do not have sysdba priviliges.
Do you also know of a good white paper that covers the step by step instructions and permissions needed for aquiring and applying/activating sqlplans?
If more information is needed in order to respond please advise.
Thank youWhat permission are needed for a user to apply/activate sql tuning sets (sql plans) in 11g? The user can capture and move the the sql tuning sets from a 10g database to an 11g database but is getting "ORA-01031: insufficient privileges" when trying to activate/apply the sqlplans in 11g.
The user has:
ADMINISTER SQL MANAGEMENT OBJECT and ADMINISTER SQL TUNING SET and EXECUTE on SYS.DBMS_SPM
The user is an administrator for our Data Warehouse team but they do not have sysdba priviliges.
Do you also know of a good white paper that covers the step by step instructions and permissions needed for aquiring and applying/activating sqlplans?
If more information is needed in order to respond please advise.
Thank you -
SQL tuning suggestions.
Hi
I am not a sql programmer and developers have given me this sql to have a look. I made the following recommendations after going through the sql. Is there anything else that can be added . I did not add about stats because they are representative and up to date.
SELECT /*+ PARALLEL(q1,4) */ *
FROM
(SELECT /*+ FIRST_ROWS(20) */
br.resource_id,
br.resource_code,
x.resource_seq_num employee_resource_number,
br.organization_id,
bd.department_id,
bd.department_code,
pf.full_name employee_name,
(SELECT xxdl_eam_util_pkg.xxdl_eam_get_resource_code(pf.person_id, bd.department_id)
FROM dual)
maximum_cost_resource,
pf.person_id,
x.wip_entity_id wo_id,
(SELECT weo1.wip_entity_name
FROM wip_eam_work_orders_v weo1
WHERE weo1.wip_entity_id = x.wip_entity_id)
wo_number,
CAST(x.start_date AS
TIMESTAMP) start_date,
CAST(x.completion_date AS
TIMESTAMP) completion_date,
wor.operation_seq_num wo_operation_number,
wor.resource_seq_num wo_resource_number,
wor.usage_rate_or_amount HOURS,
BRE.effective_start_date instance_start_date,
BRE.effective_end_date instance_end_date,
BRE.instance_id,
crc.resource_rate AS
resource_cost,
(SELECT xxdl_eam_util_pkg.xxdl_eam_get_all_res_code(pf.person_id, bd.department_id)
FROM dual)
all_resources
FROM per_all_people_f pf,
wip_eam_work_orders_v weo,
wip_operations wo,
wip_operation_resources wor,
(SELECT instance_id,
wip_entity_id,
operation_seq_num,
resource_seq_num,
start_date,
completion_date
FROM wip_op_resource_instances_v) x,
bom_dept_res_instances bdri,
bom_resource_employees BRE,
bom_department_resources bdr,
bom_resources br,
cst_resource_costs crc,
bom_departments bd
WHERE br.organization_id = bd.organization_id
AND bdr.resource_id = br.resource_id
AND bdr.department_id = bd.department_id
AND BRE.resource_id = br.resource_id
AND pf.effective_start_date <=sysdate
AND pf.effective_end_date >= sysdate
AND pf.person_id = BRE.person_id
AND wo.department_id = bd.department_id
AND wor.operation_seq_num(+) = wo.operation_seq_num
AND wor.wip_entity_id(+) = wo.wip_entity_id
AND wor.organization_id(+) = wo.organization_id
AND weo.wip_entity_id = wo.wip_entity_id
AND weo.organization_id = wo.organization_id
-- AND weo.organization_id = 6921
AND DECODE(bd.disable_date,null, sysdate,bd.disable_date) >= sysdate
AND DECODE(br.disable_date,null, sysdate,br.disable_date) >= sysdate
AND DECODE(wo.disable_date,null, sysdate,wo.disable_date) >= sysdate
AND crc.resource_id(+) = BRE.resource_id
AND x.wip_entity_id = wor.wip_entity_id
AND x.operation_seq_num = wor.operation_seq_num
AND x.resource_seq_num = wor.resource_seq_num
AND x.instance_id(+) = BRE.instance_id
AND bdri.department_id = bd.department_id
AND bdri.resource_id = br.resource_id
AND weo.organization_id = 6921
AND bdri.department_id = 5004
UNION
SELECT /*+ FIRST_ROWS(20) */ DISTINCT NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
pf.full_name employee_name,
NULL,
pf.person_id,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL HOURS,
NULL,
NULL,
NULL,
NULL,
NULL
FROM per_all_people_f pf,
wip_eam_work_orders_v weo,
wip_operations wo,
wip_operation_resources wor,
bom_dept_res_instances bdri,
bom_resource_employees BRE,
bom_department_resources bdr,
bom_resources br,
cst_resource_costs crc,
bom_departments bd
WHERE br.organization_id = bd.organization_id
AND bdr.resource_id = br.resource_id
AND bdr.department_id = bd.department_id
AND BRE.resource_id = br.resource_id
AND pf.effective_start_date <=sysdate
AND pf.effective_end_date >= sysdate
AND pf.person_id = BRE.person_id
AND wo.department_id = bd.department_id
AND wor.operation_seq_num(+) = wo.operation_seq_num
AND wor.wip_entity_id(+) = wo.wip_entity_id
AND wor.organization_id(+) = wo.organization_id
AND weo.wip_entity_id = wo.wip_entity_id
AND weo.organization_id = wo.organization_id
AND DECODE(bd.disable_date,null, sysdate,bd.disable_date) >= sysdate
AND DECODE(br.disable_date,null, sysdate,br.disable_date) >= sysdate
AND DECODE(wo.disable_date,null, sysdate,wo.disable_date) >= sysdate
AND crc.resource_id(+) = BRE.resource_id
AND bdri.department_id = bd.department_id
AND bdri.resource_id = br.resource_id
AND weo.organization_id = 6921
AND bdri.department_id = 5004
AND NOT EXISTS
(SELECT instance_id,
wip_entity_id operation_seq_num,
resource_seq_num
FROM wip_op_resource_instances_v)
) q1
ORDER BY department_id,
resource_code,
employee_name,
wo_number
My suggestions:
. Try to use UNION ALL instead of UNION. If you can eliminate UNION all together and flatten the query that will be even better.
2. You are using the function in a select statement xxdl_eam_util_pkg.xxdl_eam_get_resource_code(pf.person_id, bd.department_id)This will slow the performance. Try to get rid of this. Function calls in select are expensive.
3. Dont use the parallel hint and optimize. It wont get you consistent results.
4. Use of per_all_people_F is expensive. The UNION again complicates things. per_all_people_f has to be scanned 2x times.
5. Where does the application get the values for department id? Whether user inputs a value or whether it is hard coded . Most likely user will input value and each time it may be different. If that is the case, then you may be hitting bind peeking. There is not much hope for this. Not much can be done. Whatever you do this can happen. Only way is to pin the plan if you can use literals instead of binds. But that is not possible I think.
6. AND DECODE(bd.disable_date,null, sysdate,bd.disable_date) >= sysdate
AND DECODE(br.disable_date,null, sysdate,br.disable_date) >= sysdate
AND DECODE(wo.disable_date,null, sysdate,wo.disable_date) >= sysdate
Those statements, if you can rewrite would be good. If there are indexes on any of those columns, they are more than likely not used.
7. Are the outer joins really required. If not required remove them.
8. There is a 'WITH' clause in 10g . Try to use that for your subqueries or main query where applicable. It will save some I/O.
9. Try to tune without any hints. Remove the first rows as well and see the difference.
I know that the sql is definately bad and can be rewritten but I am not able to exactly write it for them.
Any inputs or thoughts?
MSKHi,
Any suggestions for reading on Sql tuning
I am looking for a practical book with solutions .
And books showing the Sql internal workings ?Take a look on Amazon some Jonathan Lewis books.
I will also recommend you to take a look on the following blogs:
- http://jonathanlewis.wordpress.com/
- http://www.juliandyke.com/
- http://richardfoote.wordpress.com/
- http://tkyte.blogspot.com/
And also any good interview based good Oracle DBA books ?You can take a look on my blog for some common DBA interview questions.
http://oraclenz.com/category/interview-tips/
Regards,
Francisco Munoz Alvarez
www.oraclenz.com -
SQL AlwaysOn Availability Group modifies preferred owner node on move/failover
I have a two node Windows Server 2012 R2 failover cluster with two SQL Server 2012 Enterprise AlwaysOn Availability groups configured. Within the cluster I have configured a preference order on which node a AlwaysOn Availability Group should run.
Get-ClusterGroup -Name "AlwaysOn1" | Set-ClusterOwnerNode -Owners "node1","node2";
Get-ClusterGroup -Name "AlwaysOn2" | Set-ClusterOwnerNode -Owners "node2","node1";
After configuring the preference and retrieving the preference order it is configured as it should be. When I do a failover the preference order is adjusted to first the node it currently runs on and second the other node instead of leaving the preference
order as it was. It doesn't matter if I use the PowerShell "Move-ClusterGroup" or the "ALTER AVAILABILITY GROUP [AlwaysOn1] FAILOVER" T-SQL command. From the cluster log it is shown that the preference is modified after the resource
has been moved.
INFO [GUM] Node 2: executing request locally, gumId:15859, my action: /rcm/gum/SetGroupPreferredOwners, # of updates: 1
INFO [RCM] rcm::RcmGum::SetGroupPreferredOwners(AlwaysOn1,<vector len='2'>
The default groups within the cluster "Available Storage" and "Cluster Group" keep their preference setting when configured (only configured for testing to verify it has to do with the SQL Server Availability Group resource type).
The Windows Server 2012 R2 servers are updated using the latest Windows Updates and SQL 2012 has build number 11.0.5556.
For other cluster groups which I have configured in the past like file, Hyper-V (used for affinity to get VM's which have a lot of traffic between them within the same virtual switch to reduce latency and additional hops. it would be nice if vNext will have
a affinity option for cluster groups besides the anti-affinity within the current version)
I would like to know if someone could explain why the SQL Server Availability Group resource always modifies the group preference. I might understand this with a three node cluster where the first two are running in Synchronous commit mode and the third
one in Asynchronous commit mode.
Thanks in advance,
Dennis van den AkkerHi Dennis van den Akker,
Do not use the Failover Cluster Manager to manipulate availability groups, for example:
Do not add or remove resources in the clustered service (resource group) for the availability group.
Do not change any availability group properties, such as the possible owners and preferred owners. These properties are set automatically by the availability group.
Do not use the Failover Cluster Manager to move availability groups to different nodes or to fail over availability groups. The Failover Cluster Manager is not aware of the synchronization status of the availability replicas, and doing so can lead to extended
downtime. You must use Transact-SQL or SQL Server Management Studio.
The related KB:
Failover Clustering and AlwaysOn Availability Groups (SQL Server)
https://msdn.microsoft.com/en-us/library/ff929171.aspx
The similar thread:
SQL Server Clustering 2008 (Multi Node)
https://social.msdn.microsoft.com/Forums/sqlserver/zh-CN/c35fe863-3fed-4a6e-830b-b79aa032c198/sql-server-clustering-2008-multi-node?forum=sqldisasterrecovery
Best Regards,
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
SQL Tuning using Enterprise manager in oracle 10g
Hi,
In oracle 10g you have the enterprise manager which can be used to tune sql statements using the SQL Tuning ADvisor and SQL access advisor.
I believe in oracle 10g the process of SQL Tuning is slightly easier using the Enterprise Manager ...so if some one could explain me that process...
Again thanking you in advance
regds
Manoj GokhaleHi Manoj,
Didn't you already start two other threads about this same question the SQL forum?
How do i do the SQL Statement tuning
Enterprise Manager - sql tuning advisor , Access advisor for SQL Tuning
Maybe you are looking for
-
INCOMING AND OUTGOING EXCISE INVOICE REQUIREMENT
HI, My client requires, while doing the Incoming and outgoing excise invocies based on material type traded goods and rawmaterial goods, they want to hit different GL accounts based on the materials(traded and rawmaterial separately). Since excise
-
BI Publisher Report for Archived OIM tables
Hi We perfomed Request archival operation in our OIM DB using http://docs.oracle.com/cd/E29505_01/doc.1111/e14308/archival_utilities.htm. Now ARCH* tables are created and it has relevant details. Now our requirment is to create a new report to read d
-
Error in ise for a embedded processor system
Hello, I added a .xmp file from xps to ISE-14.2 , it is having a peripheral attached with the microblaze. While translating it is giving error like : ERROR:EDK - :EDK:4110 - IPNAME: mesh3, INSTANCE: mesh3_0 - cannot find MPD for the pcore 'mesh3_v1_0
-
HT203167 Can't find my purchased. Ringtones
Can't seem to find none of my purchased ringtones to put them on my phone???? They are not under purchased!!! But are in my Purchase History
-
Whether I try to install Saros from the Marketplace, Install New Software, or drag and dropping a link into the workspace it always returns "Unable to read repository at ..." Connection reset Please find the error event at the following imgur: i.imgu