Prompt on DATE forces FULL TABLE SCAN
When using a prompt on a datetime field OBIEE sends a SQL to the Database with the TIMESTAMP COMMAND.
Due to Timestamp the Oracle database does a Full Table Scan. The field ATIST is a date with time on the physical database.
By Default ATIST was configured as TIMESTAMP in the rpd physical layer. The SQL request is sent to a Oracle 10 Database.
That is the query sent to the database:
-------------------- Sending query to database named PlantControl1 (id: <<10167>>):
select distinct T1471.ATIST as c1,
T1471.GUTMENGEMELD2 as c2
from
AGRUECK T1471 /* Fact_ARBEITSGANGMELDUNGEN */
where ( T1471.ATIST = TIMESTAMP '2005-04-01 13:48:05' )
order by c1, c2
The result takes more than half a minute to appear.
Because BIEE is using "TIMESTAMP" , the database performs a full table scan instead of using the index.
By using TO_DATE instead of timestamp the result appears after a second.
select distinct T1471.ATIST, T1471.GUTMENGEMELD2 as c2
from
AGRUECK T1471 /* Fact_ARBEITSGANGMELDUNGEN */
where ( T1471.ATIST = to_date('2005.04.01 13:48:05', 'yyyy.mm.dd hh24:mi:ss') );
Is there any way resolving the issue?
PS:When the field ATIST is configured as date at the physical layer the SQL performs well is it uses the command "to_date" instead of "timestamp". But this cuts the time of the date, When it is configured as DATETIME, OBIEE uses TIMESTAMP again.
What I need is a working date + time field.
Anybody has encountered a similiar problem?
To be honest I haven't come across many scenarios where the Time has been important. Most of our reporting stops at Day level.
What is the real world business question being asked here that requires DayTime?
Incidentally if you change your datatype on the base table you will see it works fine.
CREATE TABLE daytime( daytime TIMESTAMP );
CREATE UNIQUE INDEX dt ON daytime (daytime)
SQL> set autotrace traceonly
SQL> SELECT * FROM daytime
2 WHERE daytime = TIMESTAMP '2007-04-01 13:00:45';
no rows selected
Execution Plan
Plan hash value: 3985400340
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 13 | 1 (0)| 00:00:01 |
|* 1 | INDEX UNIQUE SCAN| DT | 1 | 13 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("DAYTIME"=TIMESTAMP' 2007-04-01 13:00:45.000000000')
Statistics
1 recursive calls
0 db block gets
1 consistent gets
0 physical reads
0 redo size
242 bytes sent via SQL*Net to client
362 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processed
SQL>However if its a date it would appear to do some internal function call which I guess is the source of the problem ...
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 9 | 2 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| DAYTIME | 1 | 9 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(INTERNAL_FUNCTION("DAYTIME")=TIMESTAMP' 2007-04-01
13:00:45.000000000')
Similar Messages
-
Data Federator Full Table scan
Hi,
Is it possible to prevent a Full table scan when creating a join between tables of 2 catalogues in a Data Federator?
This is seriously hampering the development time within Data Federator Development.
I am working with IDT Beta to create a Universe based on Multiple Source. The delay is so huge when creating joins that we could revert to Universe Design Tool. I have posted it here as Data Federator gurus will have tweak about IDT as it incorporates DF within itself in BI 4.0.
Any inputs will be great.. In case this is in the wrong forums, then please move it accordingly.
VFernandesThe issue was fixed when the GA was released. This was present in Beta
-
Hi,
My Query generation needs to be fine tuned. There are several queries generated that force full table scans of large tables. My question over here is whether functions and decodes need to be removed so that the queries take full advantage of the indexes on the table? I have used decode, Sum, case functions. So does it forces a full table scan of item price table (> 200 million records) as many times I have used these functions?
How can I optimized it in more better way?How to see execution plan? Is it like explain plan you are saying? Can you please brief me on same.
My query is
Select S_ACCT_INFO.CUST_ACCT_NAM as CUST_ACCT_NAM,
S_SLS_CRMEM_ITEM.CUST_ACCT_ID as CUST_ACCT_ID,
S_SLS_CRMEM_ITEM.CUST_CNTRC_ID as CUST_CNTRC_ID,
S_MCK_ITEM.GNRC_ID as GNRC_ID,
S_MCK_ITEM.GNRC_NAM as GNRC_NAM,
S_MCK_ITEM.SELL_DSCR_TXT as SELL_DSCR_TXT,
S_MCK_ITEM.ITEM_STAT_CD_DSPSTN as ITEM_STAT_CD_DSPSTN,
S_MCK_ITEM.RETL_LBL_CNT as RETL_LBL_CNT,
S_MCK_ITEM.LBL_NAM as LBL_NAM,
S_MCK_ITEM.MFG_SIZ_QTY as MFG_SIZ_QTY,
S_SLS_CRMEM_ITEM.EM_ITEM_NUM as EM_ITEM_NUM,
S_MCK_ITEM.NDC_NUM as NDC_NUM,
S_MCK_ITEM.SPLR_ITEM_SEQ_NUM as SPLR_ITEM_SEQ_NUM,
S_MCK_ITEM.SPLR_ACCT_NAM as SPLR_ACCT_NAM,
S_MCK_ITEM.SPLR_ACCT_ID as SPLR_ACCT_ID,
S_MCK_ITEM.UPC_NUM as UPC_NUM,
S_IW_CNTRC_LEAD.CNTRC_LEAD_NAM as CNTRC_LEAD_NAM,
DECODE(S_SLS_CRMEM_ITEM.CNTRC_LEAD_TP_ID, NULL, 'N', 'Y') CNTRC_IND_HIST,
S_SLS_CRMEM_ITEM.CNTRC_LEAD_TP_ID as CNTRC_LEAD_TP_ID,
S_SLS_CRMEM_ITEM.SLS_DOC_NUM as SLS_DOC_NUM,
SUM(S_SLS_CRMEM_ITEM.SLS_AMT) INV_EXT_PRC_3,
S_SLS_CRMEM_ITEM.SLS_PROC_WRK_DT as SLS_PROC_WRK_DT,
CASE
WHEN S_SLS_CRMEM_ITEM.GRS_SLS_QTY <> 0 THEN
ROUND(S_SLS_CRMEM_ITEM.GRS_SLS_AMT / S_SLS_CRMEM_ITEM.GRS_SLS_QTY,
2)
ELSE
0
END INV_PRC_PKG_2,
SUM(S_SLS_CRMEM_ITEM.SLS_QTY) NET_QTY_3,
S_SLS_CRMEM_ITEM.CUST_PO_NUM as CUST_PO_NUM,
CASE
WHEN S_SLS_CRMEM_ITEM.CUST_OMIT_IND IN
('L', 'U', 'R', 'F', 'A', 'X') THEN
SUM(S_SLS_CRMEM_ITEM.ORDR_QTY - S_SLS_CRMEM_ITEM.GRS_SLS_QTY)
ELSE
0
END QTY_OMTD_MUS_1,
S_ACCT_INFO.NATL_SUB_GRP_CD as NATL_SUB_GRP_CD,
S_ACCT_INFO.CUST_STOR_NUM as CUST_STOR_NUM,
S_MCK_ITEM.PKG_SIZ as PKG_SIZ,
SUM(S_SLS_CRMEM_ITEM.GRS_SLS_QTY) INV_QTY_1,
SUM(S_SLS_CRMEM_ITEM.ORDR_QTY) ORDR_QTY_2,
SUM(S_SLS_CRMEM_ITEM.ORDR_QTY - S_SLS_CRMEM_ITEM.GRS_SLS_QTY) QTY_OMTD_1,
SUM(S_SLS_CRMEM_ITEM.GRS_RTN_QTY) RTRN_QTY_1
from S_SLS_CRMEM_ITEM
LEFT OUTER JOIN S_MCK_ACCT_ITEM_PRC ON (S_SLS_CRMEM_ITEM.CUST_ACCT_ID =
S_MCK_ACCT_ITEM_PRC.CUST_ACCT_ID AND
S_SLS_CRMEM_ITEM.EM_ITEM_NUM =
S_MCK_ACCT_ITEM_PRC.ITEM_NUM)
LEFT OUTER JOIN S_ACCT_CNTRC_LEAD_TYP ON (S_MCK_ACCT_ITEM_PRC.CUST_ACCT_ID =
S_ACCT_CNTRC_LEAD_TYP.CUST_ACCT_ID AND
S_MCK_ACCT_ITEM_PRC.CNTRC_LEAD_ID =
S_ACCT_CNTRC_LEAD_TYP.CNTRC_LEAD_ID)
LEFT OUTER JOIN S_IW_CNTRC_LEAD ON (S_MCK_ACCT_ITEM_PRC.CNTRC_LEAD_ID =
S_IW_CNTRC_LEAD.CNTRC_LEAD_ID)
INNER JOIN S_ACCT_INFO ON (S_SLS_CRMEM_ITEM.CUST_ACCT_ID =
S_ACCT_INFO.CUST_ACCT_ID)
LEFT OUTER JOIN S_VA_CUST_CNTRC ON (S_SLS_CRMEM_ITEM.CUST_ACCT_ID =
S_VA_CUST_CNTRC.CUST_ACCT_ID AND
S_SLS_CRMEM_ITEM.EM_ITEM_NUM =
S_VA_CUST_CNTRC.ITEM_NUM)
INNER JOIN S_MCK_ITEM ON (S_SLS_CRMEM_ITEM.EM_ITEM_NUM =
S_MCK_ITEM.EM_ITEM_NUM)
where ((((((((S_SLS_CRMEM_ITEM.CUST_ACCT_ID in ('110718') or
(S_ACCT_INFO.NATL_GRP_CD = '0227' and
S_ACCT_INFO.NATL_SUB_GRP_CD = '000001')) or
(S_ACCT_INFO.NATL_GRP_CD = '0227' and
S_ACCT_INFO.NATL_SUB_GRP_CD = '000002')) or
(S_ACCT_INFO.NATL_GRP_CD = '0227' and
S_ACCT_INFO.NATL_SUB_GRP_CD = '000003')) or
(S_ACCT_INFO.NATL_GRP_CD = '0227' and
S_ACCT_INFO.NATL_SUB_GRP_CD = '000005')) or
(S_ACCT_INFO.CUST_CHN_ID = '227' and
S_ACCT_INFO.CUST_RGN_NUM = '000001')) or
(S_ACCT_INFO.CUST_CHN_ID = '227' and
S_ACCT_INFO.CUST_RGN_NUM = '000002')) or
(S_ACCT_INFO.CUST_CHN_ID = '227' and
S_ACCT_INFO.CUST_RGN_NUM = '000003')) or
(S_ACCT_INFO.CUST_CHN_ID = '227' and
S_ACCT_INFO.CUST_RGN_NUM = '000005'))
and S_MCK_ITEM.SPLR_ACCT_ID IN
('34227', '34232', '34233', '34228', '34229', '34230', '34231',
'34235', '34236', '78063', '84230', '90014', '98014')
and (S_SLS_CRMEM_ITEM.SLS_PROC_WRK_DT between
to_date('04/01/2007', 'MM/DD/YYYY') and
to_date('06/30/2007', 'MM/DD/YYYY'))
GROUP BY S_ACCT_INFO.CUST_ACCT_NAM,
S_SLS_CRMEM_ITEM.CUST_ACCT_ID,
S_SLS_CRMEM_ITEM.CUST_CNTRC_ID,
S_MCK_ITEM.GNRC_ID,
S_MCK_ITEM.GNRC_NAM,
S_MCK_ITEM.SELL_DSCR_TXT,
S_MCK_ITEM.ITEM_STAT_CD_DSPSTN,
S_MCK_ITEM.RETL_LBL_CNT,
S_MCK_ITEM.LBL_NAM,
S_MCK_ITEM.MFG_SIZ_QTY,
S_SLS_CRMEM_ITEM.EM_ITEM_NUM,
S_MCK_ITEM.NDC_NUM,
S_MCK_ITEM.SPLR_ITEM_SEQ_NUM,
S_MCK_ITEM.SPLR_ACCT_NAM,
S_MCK_ITEM.SPLR_ACCT_ID,
S_MCK_ITEM.UPC_NUM,
S_IW_CNTRC_LEAD.CNTRC_LEAD_NAM,
DECODE(S_SLS_CRMEM_ITEM.CNTRC_LEAD_TP_ID, NULL, 'N', 'Y'),
S_SLS_CRMEM_ITEM.CNTRC_LEAD_TP_ID,
S_SLS_CRMEM_ITEM.SLS_DOC_NUM,
S_SLS_CRMEM_ITEM.SLS_PROC_WRK_DT,
CASE
WHEN S_SLS_CRMEM_ITEM.GRS_SLS_QTY <> 0 THEN
ROUND(S_SLS_CRMEM_ITEM.GRS_SLS_AMT /
S_SLS_CRMEM_ITEM.GRS_SLS_QTY,
2)
ELSE
0
END,
S_SLS_CRMEM_ITEM.CUST_PO_NUM,
S_SLS_CRMEM_ITEM.CUST_OMIT_IND,
S_ACCT_INFO.NATL_SUB_GRP_CD,
S_ACCT_INFO.CUST_STOR_NUM,
S_MCK_ITEM.PKG_SIZ
order by S_MCK_ITEM.NDC_NUM asc,
S_SLS_CRMEM_ITEM.SLS_PROC_WRK_DT asc,
S_SLS_CRMEM_ITEM.SLS_PROC_WRK_DT asc -
How to force an MV to go through a FULL TABLE SCAN...
Hi all,
I'm trying to put a HINT in to this query to have the table MV_CLNT_SCDIM_MRGE go through a full table scan. However, for some reason, the view specification I'm using doesn't seem to work. Can anyone tell me what I should be doing to force the full table scan?
SELECT
DISTINCT 1 "c1",
t1."CALNDR_DT" "c2",
t2."OFFR_CD_ID" "c3",
t2."OFFR_COMM_CHNL_DESC" "c4",
t3."TCLNT_DIM_AGE_BASED_SGMNT_CD" "c5",
t3."TCLT_DM_CURR_CLNT_BUS_SGMNT_CD" "c6",
t2."OFFR_NM" "c7",
t2."CMPGN_NM" "c8",
t3."TCLNT_DIM_CLNT_DIM_KEY" "c9",
To_number(To_char(t1."CALNDR_DT", 'YYYY')) "c10", --only yyyy
DECODE(Substr(t2."OFFR_NM", 1, 3), 'MKT', 'MKT',
DECODE(Substr(t2."OFFR_NM", 1, 2), 'DP', 'DP',
DECODE(Substr(t2."OFFR_NM", 1, 2), 'AP', 'DP',
DECODE(Substr(t2."OFFR_NM", 1, 3), 'PRO','RRO',
DECODE(Substr(t2."OFFR_NM", 1, 5), 'SCPRO','PRO',
'NORPT'))))) "c11",
t4."PGE_NM_SRC_ID" "c12",
t4."WEB_PGE_NM" "c13",
To_number(To_char(t1."CALNDR_DT", 'YYYY')) "c14",
To_number(To_char(t1."CALNDR_DT", 'MM')) "c15",
To_number(To_char(t1."CALNDR_DT", 'WW')) "c16"
FROM "OCMADM"."VTRTMT_DIM" t2,
"OCMADM"."TDT_DIM" t1,
"OCMADM"."VR_OUTBND_CNTCT" t3,
"OCMADM"."TWEB_PGE_DIM" t4
WHERE t2."TRTMT_EFFTV_STRT_DT_DIM_KEY" = t1."DT_DIM_KEY"
AND t3."TRTMT_DIM_KEY" = t2."TRTMT_DIM_KEY"
AND t3."WEB_PGE_DIM_KEY" = t4."WEB_PGE_DIM_KEY"
AND t2."CMPGN_SYS_CD" IN ( 'INT' )
AND t2."TRTMT_STATUS_CD" = 'ACTV'
AND To_number(To_char(t1."CALNDR_DT", 'YYYY')) = 2010
and t3.outbnd_cntct_dt_dim_key > 12455197 --recommended by Brian
AND DECODE(Substr(t2."OFFR_NM", 1, 3), 'MKT', 'MKT',
DECODE(Substr(t2."OFFR_NM", 1, 2),'DP', 'DP',
DECODE(Substr(t2."OFFR_NM", 1, 2),'AP', 'DP',
DECODE(Substr(t2."OFFR_NM", 1, 3),'PRO','RRO',
DECODE(Substr(t2."OFFR_NM", 1, 5), 'SCPRO','PRO',
'NORPT'))))) IN ( 'MKT', 'DP', 'PRO' )
ORDER BY "c6" ASC,
"c5" ASC,
"c8" ASC,
"c7" ASC,
"c2" ASC,
"c11" ASC,
"c10" ASC,
"c4" ASC,
"c13" ASC,
"c12" ASC,
"c15" ASC,
"c16" ASC,
"c9" ASC,
"c3" ASC
Thanks, PeteHere is the full query with the views and materialized views embedded. You can see the hints we gave this to work. I think it is one of two things... we just don't have the syntax correct or you cannot force the path of execution after a certain number of 'embedded' calls, for lack of a better term.
SELECT DISTINCT 1 "c1",
t1."CALNDR_DT" "c2",
t2."OFFR_CD_ID" "c3",
t2."OFFR_COMM_CHNL_DESC" "c4",
t3."TCLNT_DIM_AGE_BASED_SGMNT_CD" "c5",
t3."TCLT_DM_CURR_CLNT_BUS_SGMNT_CD" "c6",
t2."OFFR_NM" "c7",
t2."CMPGN_NM" "c8",
t3."TCLNT_DIM_CLNT_DIM_KEY" "c9",
To_number(To_char(t1."CALNDR_DT", 'YYYY')) "c10",
DECODE(Substr(t2."OFFR_NM", 1, 3), 'MKT', 'MKT',
DECODE(
Substr(t2."OFFR_NM", 1, 2), 'DP', 'DP'
DECODE(
Substr(t2."OFFR_NM", 1, 2), 'AP', 'DP'
DECODE(
Substr(t2."OFFR_NM", 1, 3), 'PRO',
'RRO',
DECODE(
Substr(t2."OFFR_NM", 1, 5), 'SCPRO',
'PRO',
'NORPT'))))) "c11",
t4."PGE_NM_SRC_ID" "c12",
t4."WEB_PGE_NM" "c13"
FROM "OCMADM"."VTRTMT_DIM" t2,
"OCMADM"."TDT_DIM" t1,
( SELECT /*+ FULL(mv_hhld_dim) FULL(clnt_scdim_mrge) */ tclnt_cmpgn_outbnd_cntct_fact.clnt_cmpgn_outbnd_cntct_key,
tclnt_cmpgn_outbnd_cntct_fact.outbnd_cntct_dt_dim_key,
tclnt_cmpgn_outbnd_cntct_fact.trtmt_dim_key,
tclnt_cmpgn_outbnd_cntct_fact.clnt_scdim_key,
tclnt_cmpgn_outbnd_cntct_fact.cmpgn_evnt_typ_dim_key,
tclnt_cmpgn_outbnd_cntct_fact.web_pge_dim_key,
tclnt_cmpgn_outbnd_cntct_fact.cmpgn_sys_cd,
tclnt_cmpgn_outbnd_cntct_fact.cntct_tm_dim_key,
tclnt_cmpgn_outbnd_cntct_fact.etl_procs_key,
tclnt_cmpgn_outbnd_cntct_fact.etl_ld_ts,
mv_clnt_dim.tclnt_dim_clnt_dim_key,
mv_clnt_dim.tclnt_dim_po_id,
mv_clnt_dim.tclnt_dim_po_typ_cd,
mv_clnt_dim.tclnt_dim_best_age,
mv_clnt_dim.tclnt_dim_age_based_sgmnt_cd,
mv_clnt_dim.tclnt_dim_gendr_cd,
mv_clnt_dim.tclnt_dim_prspct_incpt_dt,
mv_clnt_dim.tclnt_dim_entry_dt,
mv_clnt_dim.tclnt_dim_brth_dt,
mv_clnt_dim.tclnt_dim_wealth_rnking_cd,
mv_clnt_dim.tclt_dm_curr_clnt_bus_sgmnt_cd,
mv_hhld_dim.hhld_dim_key,
mv_hhld_dim.hhld_id,
mv_hhld_dim.hhld_bus_sgmnt_cd
FROM OCMADM.tclnt_cmpgn_outbnd_cntct_fact tclnt_cmpgn_outbnd_cntct_fact
INNER JOIN OCMADM.mv_clnt_scdim_mrge clnt_scdim_mrge
ON clnt_scdim_mrge.tclnt_scdim_clnt_scdim_key =
tclnt_cmpgn_outbnd_cntct_fact.clnt_scdim_key
INNER JOIN OCMADM.mv_clnt_dim mv_clnt_dim
ON mv_clnt_dim.tclnt_dim_clnt_dim_key =
clnt_scdim_mrge.tclnt_mrge_mrged_to_clnt_key
INNER JOIN (SELECT /*+ FULL(mv) */ THHLD_CLNT_BRDG.HHLD_CLNT_BRDG_KEY AS THHLD_CLNT_BRDG_KEY,
THHLD_CLNT_BRDG.HHLD_DIM_KEY AS THHLD_CLNT_BRDG_HHLD_DIM_KEY,
THHLD_CLNT_BRDG.STRT_DT_DIM_KEY AS THHLD_CLT_BRDG_STRT_DT_DIM_KEY,
THHLD_CLNT_BRDG.END_DT_DIM_KEY AS THHLD_CLT_BRDG_END_DT_DIM_KEY,
MV.TCLNT_SCDIM_CLNT_SCDIM_KEY AS TCLNT_SCDIM_CLNT_SCDIM_KEY,
MV.TCLNT_SCDIM_CLNT_DIM_KEY AS TCLNT_SCDIM_CLNT_DIM_KEY,
MV.TCLNT_SCDIM_BUS_SGMNT_CD AS TCLNT_SCDIM_BUS_SGMNT_CD,
MV.TCLNT_SCDIM_SGMNTN_RNK_NO AS TCLNT_SCDIM_SGMNTN_RNK_NO,
MV.TCLNT_SCDIM_STRT_DT_DIM_KEY AS TCLNT_SCDIM_STRT_DT_DIM_KEY,
MV.TCLNT_SCDIM_END_DT_DIM_KEY AS TCLNT_SCDIM_END_DT_DIM_KEY,
MV.TCLNT_MRGE_MRGED_TO_CLNT_KEY AS TCLNT_MRGE_MRGED_TO_CLNT_KEY,
MV.TCLNT_MRGE_MRGED_FR_CLNT_KEY AS TCLNT_MRGE_MRGED_FR_CLNT_KEY,
MV.TCLNT_MRGE_STRT_DT_DIM_KEY AS TCLNT_MRGE_STRT_DT_DIM_KEY,
MV.TCLNT_MRGE_END_DT_DIM_KEY AS TCLNT_MRGE_END_DT_DIM_KEY
FROM OCMADM.MV_CLNT_SCDIM_MRGE MV,
OCMADM.THHLD_CLNT_BRDG THHLD_CLNT_BRDG
WHERE THHLD_CLNT_BRDG.CLNT_SCDIM_KEY = MV.TCLNT_SCDIM_CLNT_SCDIM_KEY
AND MV.TCLNT_SCDIM_END_DT_DIM_KEY = 15373484
AND MV.TCLNT_MRGE_END_DT_DIM_KEY = 15373484
AND THHLD_CLNT_BRDG.END_DT_DIM_KEY = 15373484) v_hhld_clnt_brdg
ON v_hhld_clnt_brdg.tclnt_mrge_mrged_to_clnt_key =
mv_clnt_dim.tclnt_dim_clnt_dim_key
INNER JOIN OCMADM.mv_hhld_dim mv_hhld_dim
ON mv_hhld_dim.hhld_dim_key =
v_hhld_clnt_brdg.thhld_clnt_brdg_hhld_dim_key
WHERE v_hhld_clnt_brdg.thhld_clt_brdg_end_dt_dim_key = 15373484) t3,
"OCMADM"."TWEB_PGE_DIM" t4
WHERE t2."TRTMT_EFFTV_STRT_DT_DIM_KEY" = t1."DT_DIM_KEY"
AND t3."TRTMT_DIM_KEY" = t2."TRTMT_DIM_KEY"
AND t3."WEB_PGE_DIM_KEY" = t4."WEB_PGE_DIM_KEY"
AND t2."CMPGN_SYS_CD" IN ( 'INT' )
AND t2."TRTMT_STATUS_CD" = 'ACTV'
AND To_number(To_char(t1."CALNDR_DT", 'YYYY')) = 2010
AND DECODE(Substr(t2."OFFR_NM", 1, 3), 'MKT', 'MKT',
DECODE(Substr(t2."OFFR_NM", 1, 2),
'DP',
'DP'
DECODE
Substr(t2."OFFR_NM", 1, 2), 'AP', 'DP'
DECODE(
Substr(t2."OFFR_NM", 1, 3), 'PRO',
'RRO',
DECODE(
Substr(t2."OFFR_NM", 1, 5), 'SCPRO',
'PRO',
'NORPT'))))) IN ( 'MKT', 'DP', 'PRO' )
ORDER BY "c6" ASC,
"c5" ASC,
"c8" ASC,
"c7" ASC,
"c2" ASC,
"c11" ASC,
"c10" ASC,
"c4" ASC,
"c12" ASC,
"c13" ASC,
"c9" ASC,
"c3" ASC -
Function based indexes doing full table scan
Guys,
I am testing function based indexes and whatever I do
it is doing a full table scan.
1)I have set the following init parameters as
QUERY_REWRITE_ENABLED=TRUE
QUERY_REWRITE_INTEGRITY=TRUSTED
2)CREATE INDEX i3 ON emp(UPPER(ename));
3) ANALYZE TABLE emp COMPUTE STATISTICS
ANALYZE INDEX I3 COMPUTE STATISTICS
4) DELETE plan_table;
5) EXPLAIN PLAN SET statement_id='Test1' FOR
SELECT ename FROM emp WHERE UPPER(ename) = 'KING';
6) SELECT LPAD(' ',2*level-2)||operation||' '||options||' '||object_name
query_plan
FROM plan_table
WHERE statement_id='Test1'
CONNECT BY prior id = parent_id
START WITH id = 0 order by id
7) And the query plan shows as
SELECT STATEMENT
TABLE ACCESS FULL EMP
I am using 9.0.1.4 !!!
Any help is appreciated !!!
Regards,
A.KishoreOne of the many new features in Oracle 8i is the Function-Based Index (we will refrain from using FBI, but only just). This allows the DBA to create indexes on functions or expressions; these functions can be user generated pl/sql functions, standard SQL functions (non-aggregate only) or even a C callout.
A classic problem the DBA faces in SQL Tuning is how to tune those queries that use function calls in the where clause, and result in indexes created on these columns not to be used.
Example
Standard B-Tree index on SURNAME with cost based optimizer
create index non_fbi on sale_contacts (surname);
analyze index non_fbi compute statistics;
analyze table sale_contacts compute statistics;
SELECT count(*) FROM sale_contacts
WHERE UPPER(surname) = 'ELLISON';
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=1 Bytes=17)
1 0 SORT (AGGREGATE)
2 1 TABLE ACCESS (FULL) OF 'SALES_CONTACTS' (Cost=3 Card=16 Bytes=272)
Now we use a function based index
create index fbi on sale_contacts (UPPER(surname));
analyze index fbi compute statistics;
analyze table sale_contacts compute statistics;
SELECT count(*) FROM sale_contacts WHERE UPPER(surname) = 'ELLISON';
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=17)
1 0 SORT (AGGREGATE)
2 1 INDEX (RANGE SCAN) OF 'FBI' (NON-UNIQUE) (Cost=2 Card=381 Bytes=6477)
The function-based index has forced the optimizer to use index range scans (retuning zero or more rowids) on the surname column rather than doing a full table scan (non-index lookup). Optimal performance does vary depending on table size, uniqueness and selectivity of columns, use of fast full table scans etc. Therefore try both methods to gain optimal performance in your database.
It is important to remember that the function-based B*Tree index does not store the expression results in the index but uses an "expression tree". The optimizer performs expression matching by parsing the expression used in the SQL statement and comparing the results against the expression-tree values in the function-based index. This comparison IS case sensitive (ignores spaces) and therefore your function-based index expressions should match expressions used in the SQL statement where clauses.
Init.ora Parameters
The following parameter must be set in your parameter file: QUERY_REWRITE_INTEGRITY = TRUSTED
QUERY_REWRITE_ENABLED = TRUE
COMPATIBLE = 8.1.0.0.0 (or higher)
Grants
Grants To create function-based indexes the user must be granted CREATE INDEX and QUERY REWRITE, or alternatively be granted CREATE ANY INDEX and GLOBAL QUERY REWRITE. The index owner must have EXECUTE access on the function used for the index. If execute access is revoked then the function-based index will be "disabled" (see dba_indexes).
Disabled Indexes
If your function-based index has a status of "disabled" the DBA can do one of the following:
a) drop and create the index (take note of its current settings)
b) alter index enable, function-based indexes only, also use disable keyword as required
c) alter index unusable.
Queries on a DISABLED index fail if the optimizer chooses to use the index.Here is an example ORA error:
ERROR at line 1: ORA-30554: function-based index MYUSER.FBI is disabled.
All DML operations on a DISABLED index also fail unless the index is also marked UNUSABLE and the initialization parameter SKIP_UNUSABLE_INDEXES is set to true.
Some more Examples
CREATE INDEX expression_ndx
ON mytable ((mycola + mycolc) * mycolb);
SELECT mycolc FROM mytable
WHERE (mycola + mycolc) * mycolb <= 256;
..or a composite index..
CREATE INDEX example_ndx
ON myexample (mycola, UPPER(mycolb), mycolc);
SELECT mycolc FROM myexample
WHERE mycola = 55 AND UPPER(mycolb) = 'JONES';
Restriction & Rule Summary
The following restrictions apply to function based indexes. You may not index:
a) LOB columns
b) REF
c) Nested table column
d) Objects types with any of the above data types.
Function-based indexes must always follow these rules:
a) Cost Based optimizer only, must generate statistics after the index is created
b) Can not store NULL values (function can not return NULL under any circumstance)
c) If a user defined pl/sql routine is used for the function-based index, and is invalidated, the index will become "disabled"
d) Functions must be deterministic (always return the same value for a known input)
e) The index owner must have "execute" access on function used in the function-based index. Revocation of the privilege will render the index "disabled"
f) May have a B-Tree and Bitmap index type only
g) Can not use expressions that are based on aggregate functions, ie. SUM, AVG etc.
h) To alter a function-based index as enabled, the function used must be valid, deterministic and the signature of the function matches the signature of the function when it was created.
Joel P�rez -
"db file scattered read" too high and Query going for full table scan-Why ?
Hi,
I had a big table of around 200mb and had a index on it.
In my query I am using the where clause which has to use the
index. I am neither using any not null condition
nor using any function on the index fields.
Still my query is not using the index.
It is going for full table scan.
Also the statspack report is showing the
"db file scattered read" too high.
Can any body help and suggest me why this is happenning.
Also tell me the possible solution for it.
Thanks
Arun Tayal"db file scattered read" are physical reads/multi block reads. This wait occurs when the session reading data blocks from disk and writing into the memory.
Take the execution plan of the query and see what is wrong and why the index is not being used.
However, FTS are not always bad. By the way, what is your db_block_size and db_file_multiblock_read_count values?
If those values are set to high, Optimizer always favour FTS thinking that reading multiblock is always faster than single reads (index scans).
Dont see oracle not using index, just find out why oracle is not using index. Use the INDEX hint to force optimizer to use index. Take the execution with/witout index and compare the cardinality,cost and of course, logical reads.
Jaffar
Message was edited by:
The Human Fly -
Select statement in a function does Full Table Scan
All,
I have been coding a stored procedure that writes 38K rows in less than a minute. If I add another column which requires call to a package and 4 functions within that package, it runs for about 4 hours. I have confirmed that due to problems in one of the functions, the code does full table scans. The package and all of its functions were written by other contractors who have been long gone.
Please note that case_number_in (VARCHAR2) and effective_date_in (DATE) are parameters sent to the problem function and I have verified through TOAD’s debugger that their values are correct.
Table named ps2_benefit_register has over 40 million rows but case_number is an index for that table.
Table named ps1_case_fs has more than 20 million rows but also uses case_number as an index.
Select #1 – causes full table scan runs and writes 38K rows in a couple of hours.
{case}
SELECT max(a2.application_date)
INTO l_app_date
FROM dwfssd.ps2_benefit_register a1, dwfssd.ps2_case_fs a2
WHERE a2.case_number = case_number_in and
a1.case_number = a2.case_number and
a2.application_date <= effective_date_in and
a1.DOCUMENT_TYPE = 'F';
{case}
Select #2 – runs – hard coding values makes the code to write the same 38K rows in a few minutes.
{case}
SELECT max(a2.application_date)
INTO l_app_date
FROM dwfssd.ps2_benefit_register a1, dwfssd.ps2_case_fs a2
WHERE a2.case_number = 'A006438' and
a1.case_number = a2.case_number and
a2.application_date <= '01-Apr-2009' and
a1.DOCUMENT_TYPE = 'F';
{case}
Why using the values in the passed parameter in the first select statement causes full table scan?
Thank you for your help,
Seyed
Edited by: user11117178 on Jul 30, 2009 6:22 AM
Edited by: user11117178 on Jul 30, 2009 6:23 AM
Edited by: user11117178 on Jul 30, 2009 6:24 AMHello Dan,
Thank you for your input. The function is not determinsitic, therefore, I am providing you with the explain plan. By version number, if you are refering to the Database version, we are running 10g.
PLAN_TABLE_OUTPUT
Plan hash value: 2132048964
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 324K| 33M| 3138 (5)| 00:00:38 | | |
|* 1 | HASH JOIN | | 324K| 33M| 3138 (5)| 00:00:38 | | |
| 2 | BITMAP CONVERSION TO ROWIDS | | 3 | 9 | 1 (0)| 00:00:01 | | |
|* 3 | BITMAP INDEX FAST FULL SCAN| IDX_PS2_ACTION_TYPES | | | | | | |
| 4 | PARTITION RANGE ITERATOR | | 866K| 87M| 3121 (4)| 00:00:38 | 154 | 158 |
| 5 | TABLE ACCESS FULL | PS2_FS_TRANSACTION_FACT | 866K| 87M| 3121 (4)| 00:00:38 | 154 | 158 |
Predicate Information (identified by operation id):
1 - access("AL1"."ACTION_TYPE_ID"="AL2"."ACTION_TYPE_ID")
3 - filter("AL2"."ACTION_TYPE"='1' OR "AL2"."ACTION_TYPE"='2' OR "AL2"."ACTION_TYPE"='S')
Thank you very much,
Seyed -
URGENT HELP Required: Solution to avoid Full table scan for a PL/SQL query
Hi Everyone,
When I checked the EXPLAIN PLAN for the below SQL query, I saw that Full table scans is going on both the tables TABLE_A and TABLE_B
UPDATE TABLE_A a
SET a.current_commit_date =
(SELECT MAX (b.loading_date)
FROM TABLE_B b
WHERE a.sales_order_id = b.sales_order_id
AND a.sales_order_line_id = b.sales_order_line_id
AND b.confirmed_qty > 0
AND b.data_flag IS NULL
OR b.schedule_line_delivery_date >= '23 NOV 2008')
Though the TABLE_A is a small table having nearly 1 lakh records, the TABLE_B is a huge table, having nearly 2 and a half crore records.
I created an Index on the TABLE_B having all its fields used in the WHERE clause. But, still the explain plan is showing FULL TABLE SCAN only.
When I run the query, it is taking long long time to execute (more than 1 day) and each time I have to kill the session.
Please please help me in optimizing this.
Thanks,
SudhindraCheck the instruction again, you're leaving out information we need in order to help you, like optimizer information.
- Post your exact database version, that is: the result of select * from v$version;
- Don't use TOAD's execution plan, but use
SQL> explain plan for <your_query>;
SQL> select * from table(dbms_xplan.display);(You can execute that in TOAD as well).
Don't forget you need to use the {noformat}{noformat} tag in order to post formatted code/output/execution plans etc.
It's also explained in the instruction.
When was the last time statistics were gathered for table_a and table_b?
You can find out by issuing the following query:select table_name
, last_analyzed
, num_rows
from user_tables
where table_name in ('TABLE_A', 'TABLE_B');
Can you also post the results of these counts;select count(*)
from table_b
where confirmed_qty > 0;
select count(*)
from table_b
where data_flag is null;
select count(*)
from table_b
where schedule_line_delivery_date >= /* assuming you're using a date, and not a string*/ to_date('23 NOV 2008', 'dd mon yyyy'); -
How to avoid full Table scan when using Rule based optimizer (Oracle817)
1. We have a Oracle 8.1.7 DB, and the optimizer_mode is set to "RULE"
2. There are three indexes on table cm_contract_supply, which is a large table having 28732830 Rows, and average row length 149 Bytes
COLUMN_NAME INDEX_NAME
PROGRESS_RECID XAK11CM_CONTRACT_SUPPLY
COMPANY_CODE XIE1CM_CONTRACT_SUPPLY
CONTRACT_NUMBER XIE1CM_CONTRACT_SUPPLY
COUNTRY_CODE XIE1CM_CONTRACT_SUPPLY
SUPPLY_TYPE_CODE XIE1CM_CONTRACT_SUPPLY
VERSION_NUMBER XIE1CM_CONTRACT_SUPPLY
CAMPAIGN_CODE XIF1290CM_CONTRACT_SUPPLY
COMPANY_CODE XIF1290CM_CONTRACT_SUPPLY
COUNTRY_CODE XIF1290CM_CONTRACT_SUPPLY
SUPPLIER_BP_ID XIF801CONTRACT_SUPPLY
COMMISSION_LETTER_CODE XIF803CONTRACT_SUPPLY
COMPANY_CODE XIF803CONTRACT_SUPPLY
COUNTRY_CODE XIF803CONTRACT_SUPPLY
COMPANY_CODE XPKCM_CONTRACT_SUPPLY
CONTRACT_NUMBER XPKCM_CONTRACT_SUPPLY
COUNTRY_CODE XPKCM_CONTRACT_SUPPLY
SUPPLY_SEQUENCE_NUMBER XPKCM_CONTRACT_SUPPLY
VERSION_NUMBER XPKCM_CONTRACT_SUPPLY
3. We are querying the table for a particular contract_number and version_number. We want to avoid full table scan.
SELECT /*+ INDEX(XAK11CM_CONTRACT_SUPPLY) */
rowid, pms.cm_contract_supply.*
FROM pms.cm_contract_supply
WHERE
contract_number = '0000000000131710'
AND version_number = 3;
However despite of giving hint, query results are fetched after full table scan.
Execution Plan
0 SELECT STATEMENT Optimizer=RULE (Cost=1182 Card=1 Bytes=742)
1 0 TABLE ACCESS (FULL) OF 'CM_CONTRACT_SUPPLY' (Cost=1182 Card=1 Bytes=742)
4. I have tried giving
SELECT /*+ FIRST_ROWS + INDEX(XAK11CM_CONTRACT_SUPPLY) */
rowid, pms.cm_contract_supply.*
FROM pms.cm_contract_supply
WHERE
contract_number = '0000000000131710'
AND version_number = 3;
and
SELECT /*+ CHOOSE + INDEX(XAK11CM_CONTRACT_SUPPLY) */
rowid, pms.cm_contract_supply.*
FROM pms.cm_contract_supply
WHERE
contract_number = '0000000000131710'
AND version_number = 3;
But it does not work.
Is there some way without changing optimizer mode and without creating an additional index, we can use the index instead of full table scan?David,
Here is my test on a Oracle 10g database.
SQL> create table mytable as select * from all_tables;
Table created.
SQL> set autot traceonly
SQL> alter session set optimizer_mode = choose;
Session altered.
SQL> select count(*) from mytable;
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 SORT (AGGREGATE)
2 1 TABLE ACCESS (FULL) OF 'MYTABLE' (TABLE)
Statistics
1 recursive calls
0 db block gets
29 consistent gets
0 physical reads
0 redo size
223 bytes sent via SQL*Net to client
276 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> analyze table mytable compute statistics;
Table analyzed.
SQL> select count(*) from mytable
2 ;
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=11 Card=1)
1 0 SORT (AGGREGATE)
2 1 TABLE ACCESS (FULL) OF 'MYTABLE' (TABLE) (Cost=11 Card=1
788)
Statistics
1 recursive calls
0 db block gets
29 consistent gets
0 physical reads
0 redo size
222 bytes sent via SQL*Net to client
276 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> disconnect
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options -
Slow queries and full table scans in spite of context index
I have defined a USER_DATASTORE, which uses a PL/SQL procedure to compile data from several tables. The master table has 1.3 million rows, and one of the fields being joined is a CLOB field.
The resulting token table has 65,000 rows, which seems about right.
If I query the token table for a word, such as "ORACLE" in the token_text field, I see that the token_count is 139. This query returns instantly.
The query against the master table is very slow, taking about 15 minutes to return the 139 rows.
Example query:
select hnd from master_table where contains(myindex,'ORACLE',1) > 0;
I've run a sql_trace on this query, and it shows full table scans on both the master table and the DR$MYINDEX$I table. Why is it doing this, and how can I fix it?After looking at the tuning FAQ, I can see that this is doing a functional lookup instead of an indexed lookup. But why, when the rows are not constrained by any structural query, and how can I get it to instead to an indexed lookup?
Thanks in advance,
Annie -
Simple Query in Oracle Linked Table in MS Access causes full table scan.
I am running a very simple query in MS ACCESS to a linked Oracle table as follows:
Select *
From EXPRESS_SERVICE_EVENTS --(the linked table name refers to EXPRESS.SERVICE_EVENTS)
Where performed > MyDate()
or
Select *
From EXPRESS_SERVICE_EVENTS --(the linked table name refers to EXPRESS.SERVICE_EVENTS)
Where performed > [Forms]![MyForm]![Date1]
We have over 50 machines and this query runs fine on over half of these, using an Oracle Index on the "performed" field. Running exactly the same thing on the other machines causes a full table scan, therefore ignoring the Index (all machines access the same Access DB).
Strangely, if we write the query as follows:
Select *
From EXPRESS_SERVICE_EVENTS
Where performed > #09/04/2009 08:00#
it works fast everywhere!
Any help on this 'phenominon' would be appreciated.
Things we've done:
Checked regional settings, ODBC driver settings, MS Access settings (as in Tools->Options), we have the latest XP and Office service packs, and re-linked all Access Tables on both the slow and fast machines independantly).Primarily, thanks gdarling for your reply. This solved our problem.
Just a small note to those who may be using this thread.
Although this might not be the reason, my PC had Oracle 9iR2 installed with Administratiev Tools, where user machines had the same thing installed but using Runtime Installation. For some reason, my PC did not have 'bind date' etc. as an option in the workarounds, but user machines did have this workaround option. Strangely, although I did not have the option, my (ODBC) query was running as expected, but user queries were not.
When we set the workaround checkbox accordingly, the queries then run as expected (fast).
Once again,
Thanks -
Taking more time in INDEX RANGE SCAN compare to the full table scan
Hi all ,
Below are the version og my database.
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for HPUX: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
I have gather the table statistics and plan change for sql statment.
SELECT P1.COMPANY, P1.PAYGROUP, P1.PAY_END_DT, P1.PAYCHECK_OPTION,
P1.OFF_CYCLE, P1.PAGE_NUM, P1.LINE_NUM, P1.SEPCHK FROM PS_PAY_CHECK P1
WHERE P1.FORM_ID = :1 AND P1.PAYCHECK_NBR = :2 AND
P1.CHECK_DT = :3 AND P1.PAYCHECK_OPTION <> 'R'
Plan before the gather stats.
Plan hash value: 3872726522
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | *14306* (100)| |
| 1 | *TABLE ACCESS FULL| PS_PAY_CHECK* | 1 | 51 | 14306 (4)| 00:02:52 |
Plan after the gather stats:
Operation Object Name Rows Bytes Cost
SELECT STATEMENT Optimizer Mode=CHOOSE
1 4
*TABLE ACCESS BY INDEX ROWID SYSADM.PS_PAY_CHECK* 1 51 *4*
*INDEX RANGE SCAN SYSADM.PS0PAY_CHECK* 1 3After gather stats paln look good . but when i am exeuting the query it take 5 hours. before the gather stats it finishing the within 2 hours. i do not want to restore my old statistics. below are the data for the tables.and when i am obserrving it lot of db files scatter rea
NAME TYPE VALUE
_optimizer_cost_based_transformation string OFF
filesystemio_options string asynch
object_cache_optimal_size integer 102400
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.4
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string choose
optimizer_secure_view_merging boolean TRUE
plsql_optimize_level integer 2
SQL> select count(*) from sysadm.ps_pay_check;
select num_rows,blocks from dba_tables where table_name ='PS_PAY_CHECK';
COUNT(*)
1270052
SQL> SQL> SQL>
NUM_ROWS BLOCKS
1270047 63166
Event Waits Time (s) (ms) Time Wait Class
db file sequential read 1,584,677 6,375 4 36.6 User I/O
db file scattered read 2,366,398 5,689 2 32.7 User I/Oplease let me know why it taking more time in INDEX RANGE SCAN compare to the full table scan?suresh.ratnaji wrote:
NAME TYPE VALUE
_optimizer_cost_based_transformation string OFF
filesystemio_options string asynch
object_cache_optimal_size integer 102400
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.4
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string choose
optimizer_secure_view_merging boolean TRUE
plsql_optimize_level integer 2
please let me know why it taking more time in INDEX RANGE SCAN compare to the full table scan?Suresh,
Any particular reason why you have a non-default value for a hidden parameter, optimizercost_based_transformation ?
On my 10.2.0.1 database, its default value is "linear". What happens when you reset the value of the hidden parameter to default? -
Tables in subquery resulting in full table scans
Hi,
This is related to a p1 bug 13009447. Customer recently upgraded to 10G. Customer reported this type of problem for the second time.
Problem Description:
All the tables in sub-query are resulting in full table scans and hence are executing for hours.
Here is the query
SELECT /*+ PARALLEL*/
act.assignment_action_id
, act.assignment_id
, act.tax_unit_id
, as1.person_id
, as1.effective_start_date
, as1.primary_flag
FROM pay_payroll_actions pa1
, pay_population_ranges pop
, per_periods_of_service pos
, per_all_assignments_f as1
, pay_assignment_actions act
, pay_payroll_actions pa2
, pay_action_classifications pcl
, per_all_assignments_f as2
WHERE pa1.payroll_action_id = :b2
AND pa2.payroll_id = pa1.payroll_id
AND pa2.effective_date
BETWEEN pa1.start_date
AND pa1.effective_date
AND act.payroll_action_id = pa2.payroll_action_id
AND act.action_status IN ('C', 'S')
AND pcl.classification_name = :b3
AND pa2.consolidation_set_id = pa1.consolidation_set_id
AND pa2.action_type = pcl.action_type
AND nvl (pa2.future_process_mode, 'Y') = 'Y'
AND as1.assignment_id = act.assignment_id
AND pa1.effective_date
BETWEEN as1.effective_start_date
AND as1.effective_end_date
AND as2.assignment_id = act.assignment_id
AND pa2.effective_date
BETWEEN as2.effective_start_date
AND as2.effective_end_date
AND as2.payroll_id = as1.payroll_id
AND pos.period_of_service_id = as1.period_of_service_id
AND pop.payroll_action_id = :b2
AND pop.chunk_number = :b1
AND pos.person_id = pop.person_id
AND (
as1.payroll_id = pa1.payroll_id
OR pa1.payroll_id IS NULL
AND NOT EXISTS
SELECT /*+ PARALLEL*/ NULL
FROM pay_assignment_actions ac2
, pay_payroll_actions pa3
, pay_action_interlocks int
WHERE int.locked_action_id = act.assignment_action_id
AND ac2.assignment_action_id = int.locking_action_id
AND pa3.payroll_action_id = ac2.payroll_action_id
AND pa3.action_type IN ('P', 'U')
AND NOT EXISTS
SELECT /*+ PARALLEL*/
NULL
FROM per_all_assignments_f as3
, pay_assignment_actions ac3
WHERE :b4 = 'N'
AND ac3.payroll_action_id = pa2.payroll_action_id
AND ac3.action_status NOT IN ('C', 'S')
AND as3.assignment_id = ac3.assignment_id
AND pa2.effective_date
BETWEEN as3.effective_start_date
AND as3.effective_end_date
AND as3.person_id = as2.person_id
ORDER BY as1.person_id
, as1.primary_flag DESC
, as1.effective_start_date
, act.assignment_id
FOR UPDATE OF as1.assignment_id
, pos.period_of_service_id
Here is the execution plan for this query. We tried adding hints in sub-query to force indexes to pick-up but it is still doing Full table scans.
Suspecting some db parameter which is causing this issue.
In the
- Full table scans on tables in the first sub-query
PAY_PAYROLL_ACTIONS, PAY_ASSIGNMENT_ACTIONS, PAY_ACTION_INTERLOCKS
- Full table scans on tables in Second sub-query
PER_ALL_ASSIGNMENTS_F PAY_ASSIGNMENT_ACTIONS
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 29 398.80 2192.99 238706 4991924 2383 0
Fetch 1136 378.38 1921.39 0 4820511 0 1108
total 1166 777.19 4114.38 238706 9812435 2383 1108
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 41 (APPS) (recursive depth: 1)
Rows Execution Plan
0 SELECT STATEMENT MODE: ALL_ROWS
0 FOR UPDATE
0 PX COORDINATOR
0 PX SEND (QC (ORDER)) OF ':TQ10009' [:Q1009]
0 SORT (ORDER BY) [:Q1009]
0 PX RECEIVE [:Q1009]
0 PX SEND (RANGE) OF ':TQ10008' [:Q1008]
0 HASH JOIN (ANTI BUFFERED) [:Q1008]
0 PX RECEIVE [:Q1008]
0 PX SEND (HASH) OF ':TQ10006' [:Q1006]
0 BUFFER (SORT) [:Q1006]
0 TABLE ACCESS MODE: ANALYZED (BY INDEX ROWID) OF 'PER_ALL_ASSIGNMENTS_F' (TABLE) [:Q1006]
0 NESTED LOOPS [:Q1006]
0 NESTED LOOPS [:Q1006]
0 NESTED LOOPS [:Q1006]
0 HASH JOIN (ANTI) [:Q1006]
0 BUFFER (SORT) [:Q1006]
0 PX RECEIVE [:Q1006]
0 PX SEND (HASH) OF ':TQ10002'
0 TABLE ACCESS MODE: ANALYZED (BY INDEX ROWID) OF 'PAY_ASSIGNMENT_ACTIONS' (TABLE)
0 NESTED LOOPS
0 NESTED LOOPS
0 NESTED LOOPS
0 NESTED LOOPS
0 TABLE ACCESS MODE: ANALYZED (BY INDEX ROWID) OF 'PAY_PAYROLL_ACTIONS' (TABLE)
0 INDEX MODE: ANALYZED (UNIQUE SCAN) OF 'PAY_PAYROLL_ACTIONS_PK' (INDEX (UNIQUE)
0 INDEX MODE: ANALYZED (RANGE SCAN) OF 'PAY_POPULATION_RANGES_N4' (INDEX)
0 TABLE ACCESS MODE: ANALYZED (BY INDEX ROWID) OF 'PER_PERIODS_OF_SERVICE' (TABLE)
0 INDEX MODE: ANALYZED (RANGE SCAN) OF 'PER_PERIODS_OF_SERVICE_N3' (INDEX)
0 TABLE ACCESS MODE: ANALYZED (BY INDEX ROWID) OF 'PER_ALL_ASSIGNMENTS_F' (TABLE)
0 INDEX MODE: ANALYZED (RANGE SCAN) OF 'PER_ASSIGNMENTS_N4' (INDEX)
0 INDEX MODE: ANALYZED (RANGE SCAN) OF 'PAY_ASSIGNMENT_ACTIONS_N51' (INDEX)
0 PX RECEIVE [:Q1006]
0 PX SEND (HASH) OF ':TQ10005' [:Q1005]
0 VIEW OF 'VW_SQ_1' (VIEW) [:Q1005]
0 HASH JOIN [:Q1005]
0 BUFFER (SORT) [:Q1005]
0 PX RECEIVE [:Q1005]
0 PX SEND (BROADCAST) OF ':TQ10000'
0 TABLE ACCESS MODE: ANALYZED (FULL) OF 'PAY_PAYROLL_ACTIONS' (TABLE)
0 HASH JOIN [:Q1005]
0 PX RECEIVE [:Q1005]
0 PX SEND (HASH) OF ':TQ10004' [:Q1004]
0 PX BLOCK (ITERATOR) [:Q1004]
0 TABLE ACCESS MODE: ANALYZED (FULL) OF 'PAY_ASSIGNMENT_ACTIONS' (TABLE) [:Q1004]
0 BUFFER (SORT) [:Q1005]
0 PX RECEIVE [:Q1005]
0 PX SEND (HASH) OF ':TQ10001'
0 TABLE ACCESS MODE: ANALYZED (FULL) OF 'PAY_ACTION_INTERLOCKS' (TABLE)
0 TABLE ACCESS MODE: ANALYZED (BY INDEX ROWID) OF 'PAY_PAYROLL_ACTIONS' (TABLE) [:Q1006]
0 INDEX MODE: ANALYZED (UNIQUE SCAN) OF 'PAY_PAYROLL_ACTIONS_PK' (INDEX (UNIQUE)) [:Q1006]
0 INDEX MODE: ANALYZED (UNIQUE SCAN) OF 'PAY_ACTION_CLASSIFICATIONS_PK' (INDEX (UNIQUE))[:Q1006]
0 INDEX MODE: ANALYZED (RANGE SCAN) OF 'PER_ASSIGNMENTS_F_PK' (INDEX (UNIQUE)) [:Q1006]
0 PX RECEIVE [:Q1008]
0 PX SEND (HASH) OF ':TQ10007' [:Q1007]
0 VIEW OF 'VW_SQ_2' (VIEW) [:Q1007]
0 FILTER [:Q1007]
0 HASH JOIN [:Q1007]
0 BUFFER (SORT) [:Q1007]
0 PX RECEIVE [:Q1007]
0 PX SEND (BROADCAST) OF ':TQ10003'
0 TABLE ACCESS MODE: ANALYZED (FULL) OF 'PER_ALL_ASSIGNMENTS_F' (TABLE)
0 PX BLOCK (ITERATOR) [:Q1007]
0 TABLE ACCESS MODE: ANALYZED (FULL) OF 'PAY_ASSIGNMENT_ACTIONS' (TABLE) [:Q1007]
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
enq: KO - fast object checkpoint 32 0.02 0.12
os thread startup 8 0.02 0.19
PX Deq: Join ACK 198 0.00 0.04
PX Deq Credit: send blkd 167116 1.95 1103.72
PX Deq Credit: need buffer 327389 1.95 266.30
PX Deq: Parse Reply 148 0.01 0.03
PX Deq: Execute Reply 11531 1.95 1901.50
PX qref latch 23060 0.00 0.60
db file sequential read 108199 0.17 22.11
db file scattered read 9272 0.19 51.74
PX Deq: Table Q qref 78 0.00 0.03
PX Deq: Signal ACK 1165 0.10 10.84
enq: PS - contention 73 0.00 0.00
reliable message 27 0.00 0.00
latch free 218 0.00 0.01
latch: session allocation 11 0.00 0.00
Thanks in advance
Suresh PVHi,
welcome,
how is the query performing if you delete all the hints for PARALLEL, because most of the waits are related to waits on Parallel.
Herald ten Dam
http://htendam.wordpress.com
PS. Use "{code}" for showing your code and explain plans, it looks nicer -
Where columnname like '%somevalue' causing full table scan
hi,
10.2.0.4 database
is it possible to force an index scan over a full table scan if I use a where clause similar to the following:
where col1 like '%somevalue';
There is an index with col1 as the first segment of the index and another column as the second segment of the index.
Thanks
JOhnI have done it for you
SQL> create index empX on emp(job) ;
Index created.
SQL> explain plan for select * from emp where job like '%ERK' ;
Explained.
SQL> select * from table(dbms_xplan.display) ;
PLAN_TABLE_OUTPUT
Plan hash value: 3956160932
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 37 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| EMP | 1 | 37 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("JOB" LIKE '%ERK')
13 rows selected.
SQL> explain plan for select * from emp where job like 'C%ERK' ;
Explained.
SQL> select * from table(dbms_xplan.display) ;
PLAN_TABLE_OUTPUT
Plan hash value: 140376749
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 4 | 148 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 4 | 148 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | EMPX | 4 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("JOB" LIKE 'C%ERK')
filter("JOB" LIKE 'C%ERK')
15 rows selected.
SQL> explain plan for select /*+index (emp,EMPX) */ * from emp where job like '%ERK' ;
Explained.
SQL> select * from table(dbms_xplan.display) ;
PLAN_TABLE_OUTPUT
Plan hash value: 3745534319
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 37 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 37 | 2 (0)| 00:00:01 |
|* 2 | INDEX FULL SCAN | EMPX | 1 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("JOB" LIKE '%ERK')
14 rows selected.SS -
Trunc causing Full Table Scans
I have a situtaion here where my query is as follows.
SQL> select count(1) from HBSM_SM_ACCOUNT_INFO where OPTIONAL_PARM5='MH' and CUST_STATUS in ('UP','UUP') and trunc(FIRST_ACTVN_DATE) = trunc(sysdate);
COUNT(1)
6
PLAN_TABLE_OUTPUT
Plan hash value: 3951750498
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 1 | 10 | 13904 (1)| 00:02:47 | | |
| 1 | SORT AGGREGATE | | 1 | 10 | | | | |
| 2 | PARTITION LIST SINGLE| | 1 | 10 | 13904 (1)| 00:02:47 | 12 | 12 |
|* 3 | TABLE ACCESS FULL | HBSM_SM_ACCOUNT_INFO | 1 | 10 | 13904 (1)| 00:02:47 | 12 | 12 |
Predicate Information (identified by operation id):
3 - filter(("CUST_STATUS"='UP' OR "CUST_STATUS"='UUP') AND
TO_DATE(INTERNAL_FUNCTION("FIRST_ACTVN_DATE"))=TO_DATE(TO_CHAR(SYSDATE@!)))
16 rows selected.
If I remove the trunc clause from the query the performance definitely improves the the results are wrong.
SQL> select count(1) from HBSM_SM_ACCOUNT_INFO where OPTIONAL_PARM5='MH' and CUST_STATUS in ('UP','UUP') and FIRST_ACTVN_DATE = trunc(sysdate);
COUNT(1)
0
PLAN_TABLE_OUTPUT
Plan hash value: 454529511
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 1 | 40 | 47 (0)| 00:00:01 | | |
|* 1 | TABLE ACCESS BY GLOBAL INDEX ROWID| HBSM_SM_ACCOUNT_INFO | 1 | 40 | 47 (0)| 00:00:01 | 12 | 12 |
|* 2 | INDEX RANGE SCAN | IND_FIRST_ACTVN_DATE | 51 | | 4 (0)| 00:00:01 | | |
Can someone please help me whereby I can get the right data and I can also prevent these full table scans.Unless you are using a functional index, applying any function to an indexed column prevents the use of the index.
The way round it in your case is to realise that
select count(1) from HBSM_SM_ACCOUNT_INFO where OPTIONAL_PARM5='MH' and CUST_STATUS in ('UP','UUP') and trunc(FIRST_ACTVN_DATE) = trunc(sysdate)Is really asking that FIRST_ACTVN_DATE should be sometime today. You could therefore rewrite it as
select count(1) from HBSM_SM_ACCOUNT_INFO where OPTIONAL_PARM5='MH' and CUST_STATUS in ('UP','UUP')
and FIRST_ACTVN_DATE >= trunc(sysdate)
and FIRST_ACTVN_DATE < trunc(sysdate) + 1Note, this still might not use the index depending on how many rows are within today's date versus how many are outside today's date.
Also, when posting, remember to put your code between tags and to post create table scripts and sample data inserts.
Maybe you are looking for
-
I can't remove an old credit card from my account and I can't get free apps now
I have an expired card on my account and when I try to get an app it says there's been a billing problem with the last purchase.
-
Hi . I am facing problem in displaying a particular layout in ALV. the layout is as follows: 1. Header part 2. Line item 3. There is field customer and after every change of customer do page break and display information like how many record read and
-
How can I get the list of columns (fieldcatalog) for particular variant
Hello, i have option chose variant on selection screen (REUSE_ALV_VARIANT_F4) and i need to get which fields (columns) are included in this variant - i need to get this restricted fieldcatalog according variant using FM. I need to save file only with
-
Can't import or play tracks from CD in Itunes
Hi, I am unable to import or play any of my songs from my CDs in ITunes 6.0.2. In the past, I had no problem with this. I tried selecting a song from a CD located on the ddesktop and opening Quicktime instead and I was once again unable to play the s
-
How do you change the Screen Resolution?
I can not figure out how to change the resolution on my screen. Everything is much smaller than what i would like and would like to enlarge everything. There is a simple way of doing this with a PC but i have not been able to figure it out on a macbo