Hi,
On addition of a single column, performance of a query has drastically impacted (40 secs from 0.0002 secs). Oracle has changed earlier plan and picked plan that takes more time.
Change : new column added to a query in select clause : dsig.
Time taken by old query to fetch data: 0.002 secs (plan used index access by rowid and index range scan)
Time taken by new query to fetch data: 40 secs (plan used HASH join of indexes and fast fill scan of index)
details below:
message_exchange and transaction are heavy tables.
MESSAGE_EXCHANGE :rows: 56407885
TRANSACTION : rows: 9509739
CONSTRAINT "TRANSACTION_ID_FK" FOREIGN KEY ("ID") REFERENCES TRANSACTION" ("ID")
PRIMARY KEY of TRANSACTION is ID.
PRIMARY KEY of MESSAGE_EXCHANGE is MQ_MSG_ID.
TRANSACTION table has indexes on following columns:
id, as_id, source_ep, destination_ep, creation_timestamp, source_ref_id, destination_ref_id, requestor_dn, responder_dn, lasmodify_timestamp, composite index on status and swift_error, logical_filename
MESSAGE_EXCHANGE table has indexes on following columns:
mq_msg_id and id
New query
SELECT txn.id ,
txn.as_id ,
txn.source_ep ,
txn.destination_ep ,
txn.creation_timestamp ,
txn.traffic_type ,
txn.source_ref_id ,
txn.destination_ref_id ,
txn.requestor_dn ,
txn.responder_dn ,
txn.service ,
txn.status ,
txn.lasmodify_timestamp,
txn.wf_id ,
txn.curr_wf_stage_id ,
txn.source_cl_id ,
txn.destination_cl_id ,
txn.e2e_msg_id ,
txn.mode ,
txn.ack_indicator ,
txn.deliv_notif ,
txn.deliv_responder_dn ,
txn.payload_size ,
txn.currenattempt ,
txn.snf_delivery_time ,
txn.instance_id ,
txn.exporstatus ,
txn.swiferror ,
txn.non_repudiation ,
txn.logical_filename ,
txn.fileinfo ,
txn.filedesc ,
txn.requestype ,
txn.file_digesalgo ,
txn.seq_id ,
txn.physical_filename ,
txn.snfinpuseq ,
txn.swfcomp_algo ,
txn.dsig
FROM message_exchange me,
transaction txn
WHERE me.mq_msg_id = :1
AND me.id = txn.id
new plan
################################################################
| Id | Operation | Name | Rows | Bytes | Cost |
-------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 29M | 1.4066E+10| 597636|
| 1 | NESTED LOOPS | | 29M | 1.4066E+10| 597636|
|* 2 | VIEW | index$_join$_001 | 29M | 214M| 244037|
|* 3 | HASH JOIN | | | | |
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
|* 4 | INDEX RANGE SCAN | IX_MQ_MSG_ID | 29M | 214M| 3404|
| 5 | INDEX FAST FULL SCAN | IX_ME_TXN_ID | 29M | 214M| 4718 |
| 6 | TABLE ACCESS BY INDEX ROWID| IS_TB_TRANSACTION | 1 | 400 | 1 |
|* 7 | INDEX UNIQUE SCAN | PK_TXN_ID | 1 | | 1 |
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
old query
SELECT txn.id ,
txn.as_id ,
txn.source_ep ,
txn.destination_ep ,
txn.creation_timestamp ,
txn.traffic_type ,
txn.source_ref_id ,
txn.destination_ref_id ,
txn.requestor_dn ,
txn.responder_dn ,
txn.service ,
txn.status ,
txn.lasmodify_timestamp,
txn.wf_id ,
txn.curr_wf_stage_id ,
txn.source_cl_id ,
txn.destination_cl_id ,
txn.e2e_msg_id ,
txn.mode ,
txn.ack_indicator ,
txn.deliv_notif ,
txn.deliv_responder_dn ,
txn.payload_size ,
txn.currenattempt ,
txn.snf_delivery_time ,
txn.instance_id ,
txn.exporstatus ,
txn.swiferror ,
txn.non_repudiation ,
txn.logical_filename ,
txn.fileinfo ,
txn.filedesc ,
txn.requestype ,
txn.file_digesalgo ,
txn.seq_id ,
txn.physical_filename ,
txn.snfinpuseq ,
txn.swfcomp_algo
FROM message_exchange me,
transaction txn
WHERE me.mq_msg_id = :1
AND me.id = txn.id
old plan
################################################################
| Id | Operation | Name | Rows | Bytes | Cost |
-------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 29M | 1.4066E+10| 597636|
| 1 | NESTED LOOPS | | 29M | 1.4066E+10| 597636|
|* 2 | NESTED LOOPS | | 29M | 214M | 597636|
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
|* 3 | TABLE ACCESS BY INDEX ROWID| IS_TB_MESSAGE_EXCHANGE | 29M | 214M| 289037|
| 4 | INDEX RANGE SCAN | IX_ME_TXN_ID | 29M | 214M| 2993 |
| 5 | TABLE ACCESS BY INDEX ROWID| IS_TB_TRANSACTION | 1 | 400 | 1 |
|* 6 | INDEX UNIQUE SCAN | PK_TXN_ID | 1 | | 1 |
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Thanks,
Rohit