hello ,
i have a table TDRCORE.FCM_CCBF ,
PARTITION BY RANGE (RQO_PROC_UTC_DATETIME TIMESTAMP(6))
INTERVAL( NUMTODSINTERVAL(7, 'DAY'))
tehre is an SQL running on LIVE db that comtains many unions but i will not post full script , i will post just 1 part of the union (all the other selects in this union are exatly the same , just different tables)
/* Formatted on 03-Jul-24 10:36:19 (QP5 v5.294) */
ALTER SESSION SET CURRENT_SCHEMA=TDRCORE;
EXPLAIN PLAN
FOR
WITH currTime
AS (SELECT TO_TIMESTAMP (
TO_CHAR (SYS_EXTRACT_UTC (CURRENT_TIMESTAMP),
'YYYY-MM-DD HH24:MI:SS'),
'YYYY-MM-DD HH24:MI:SS')
AS endts
FROM DUAL)
(SELECT 'FCM_CCBF' AS DBTABLE,
t26.CMX_TRAN_ID AS CMX_TRAN_ID,
t26.CMX_CREATE_TIMESTAMP,
currTime.endts,
CASE
WHEN ( ( COALESCE (t26.WAX_USER_FRAUD_A_IND, '0')
|| COALESCE (t26.WAX_USER_FRAUD_B_IND, '0')
|| COALESCE (t26.WAX_USER_FRAUD_C_IND, '0')
|| COALESCE (t26.WAX_USER_FRAUD_D_IND, '0')
|| COALESCE (t26.WAX_USER_FRAUD_H_IND, '0')
|| COALESCE (t26.WAX_USER_FRAUD_M_IND, '0')
|| COALESCE (t26.WAX_USER_FRAUD_O_IND, '0')
|| COALESCE (t26.WAX_USER_FRAUD_P_IND, '0')
|| COALESCE (t26.WAX_USER_FRAUD_R_IND, '0')
|| COALESCE (t26.WAX_USER_FRAUD_T_IND, '0')
|| COALESCE (t26.WAX_USER_FRAUD_W_IND, '0')
|| COALESCE (t26.WAX_USER_FRAUD_X_IND, '0'))) > 0
OR ( t26.WAX_SCORE_1_TAG IN ('1', '3')
OR t26.WAX_SCORE_2_TAG IN ('1', '3')
OR t26.WAX_SCORE_3_TAG IN ('1', '3')
OR t26.WAX_SCORE_4_TAG IN ('1', '3'))
THEN
1
ELSE
0
END
AS FRAUD_IND,
TRIM (t26.RRR_MODEL_ID_1) AS "RRR_MODEL_ID_1",
TRIM (t26.RRR_MODEL_ID_2) AS "RRR_MODEL_ID_2",
TRIM (t26.RRR_MODEL_ID_3) AS "RRR_MODEL_ID_3",
TRIM (t26.RRR_MODEL_ID_4) AS "RRR_MODEL_ID_4",
TRIM (t26.RRR_MODEL_SCORE_1) AS "RRR_MODEL_SCORE_1",
TRIM (t26.RRR_MODEL_SCORE_2) AS "RRR_MODEL_SCORE_2",
TRIM (t26.RRR_MODEL_SCORE_3) AS "RRR_MODEL_SCORE_3",
TRIM (t26.RRR_MODEL_SCORE_4) AS "RRR_MODEL_SCORE_4",
TRIM (t26.RRR_MODEL_VERSION_1) AS "RRR_MODEL_VERSION_1",
TRIM (t26.RRR_MODEL_VERSION_2) AS "RRR_MODEL_VERSION_2",
TRIM (t26.RRR_MODEL_VERSION_3) AS "RRR_MODEL_VERSION_3",
TRIM (t26.RRR_MODEL_VERSION_4) AS "RRR_MODEL_VERSION_4",
TRIM (t26.RRR_SCORE_1) AS "RRR_SCORE_1",
TRIM (t26.RRR_SCORE_2) AS "RRR_SCORE_2",
TRIM (t26.RRR_SCORE_3) AS "RRR_SCORE_3",
TRIM (t26.RRR_SCORE_4) AS "RRR_SCORE_4",
TRIM (t26.SMH_ACCT_TYPE) AS "SMH_ACCT_TYPE",
TRIM (t26.SMH_ACTIVITY_TYPE) AS "SMH_ACTIVITY_TYPE",
TRIM (t26.SMH_MULTI_ORG_NODE_KEY) AS "SMH_MULTI_ORG_NODE_KEY",
t26.CMX_TRAN_ID
|| '|'
|| TO_CHAR (t26.RQO_PROC_UTC_DATETIME,
'YYYY-MM-DD HH24:MI:SS.FF')
AS "_id"
FROM FCM_CCBF t26, currTime
WHERE t26.CMX_CREATE_TIMESTAMP >
TO_TIMESTAMP ('2024-03-22 11:41:53.992000',
'YYYY-MM-DD HH24:MI:SS.FF')
AND t26.CMX_CREATE_TIMESTAMP <= currTime.endts
AND t26.RQO_PROC_UTC_DATETIME BETWEEN TRUNC (
TO_TIMESTAMP (
'2024-03-22 11:41:53.992000',
'YYYY-MM-DD HH24:MI:SS.FF'))
- 10
AND currTime.endts);
SET LINESIZE 130
SET PAGESIZE 0
SELECT * FROM TABLE (DBMS_XPLAN.DISPLAY);
the possible issue is TABLE ACCESS FULL part :
-------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
-------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 131M| 21G| 26M (1)| 00:00:54 | | |
|* 1 | FILTER | | | | | | | |
| 2 | NESTED LOOPS | | 131M| 21G| 26M (1)| 00:00:54 | | |
| 3 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 | | |
| 4 | PARTITION RANGE ITERATOR| | 131M| 21G| 26M (1)| 00:00:54 | 2829 | KEY |
|* 5 | TABLE ACCESS FULL | FCM_CCBF | 131M| 21G| 26M (1)| 00:00:54 | 2829 | KEY |
-------------------------------------------------------------------------------------------------------
there is an partitioned index on CMX_CREATE_TIMESTAMP
CREATE INDEX TDRCORE.NDX5_CCBF ON TDRCORE.FCM_CCBF
(CMX_CREATE_TIMESTAMP)
TABLESPACE TDR_INDEX
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
BUFFER_POOL DEFAULT
)
LOCAL
there are no GLOBAL indexes on the table .
all the statistics are fresh .
is it possible that issue is with convertion , if not i am at loss , how can i eliminate TABLE ACCESS FULL ?
thank you
Assuming your stats are up to date, I think its very wise that the database decided *not* to use your index.
We are getting 130million rows from that table - 130million index probes could be massively expensive.
The "PARTITION RANGE ITERATOR" says it used to the timestamp predicate to make sure we started at partition 2829, so we bypassed the first 2828 partitions.
Looks to me like the query is bring run exactly as it should be