Confio oracle enq tm contention wait
-
Upload
confio-software -
Category
Technology
-
view
1.517 -
download
4
description
Transcript of Confio oracle enq tm contention wait
![Page 1: Confio oracle enq tm contention wait](https://reader036.fdocuments.us/reader036/viewer/2022082606/5583f565d8b42afa438b4e2f/html5/thumbnails/1.jpg)
04/13/2023 1
Solving Oracle enq: TM Contention Wait Events: A Case Study
Dean Richards, Sr. DBA Confio Software
![Page 2: Confio oracle enq tm contention wait](https://reader036.fdocuments.us/reader036/viewer/2022082606/5583f565d8b42afa438b4e2f/html5/thumbnails/2.jpg)
04/13/2023 2
Case study: Customer experienceing enq: TM waits
• Sessions blocked on customer’s database• enq: TM – contention wait events• Executing simple INSERT statements similar to:
INSERT INTO supplier VALUES (:1, :2, :3);
![Page 3: Confio oracle enq tm contention wait](https://reader036.fdocuments.us/reader036/viewer/2022082606/5583f565d8b42afa438b4e2f/html5/thumbnails/3.jpg)
04/13/2023 3
What’s going on?
• Reviewed the SUPPLIER table– Found a foreign key constraint referencing the
PRODUCT table that didn’t have an associated index
• Confirmed by reviewing Top Objects in Ignite– All the wait time was associated with the
PRODUCT table
![Page 4: Confio oracle enq tm contention wait](https://reader036.fdocuments.us/reader036/viewer/2022082606/5583f565d8b42afa438b4e2f/html5/thumbnails/4.jpg)
04/13/2023 4
How did we fix it?
• Added index on the column referencing the PRODUCT table
• Found the blocking sessions using Ignite—what was happening?– Periodically, the company reviewed its vendor list
and "cleaned up” SUPPLIER table– As a result, rows from SUPPLIER table were
deleted– Those DELETE statements then cascaded to the
PRODUCT table and took out TM locks on it
![Page 5: Confio oracle enq tm contention wait](https://reader036.fdocuments.us/reader036/viewer/2022082606/5583f565d8b42afa438b4e2f/html5/thumbnails/5.jpg)
04/13/2023 5
What’s really happening under the covers?
• Reproduced customer’s issue to see what happens under the covers– Created a subset of the tables from this customer and loaded them
with sample data
![Page 6: Confio oracle enq tm contention wait](https://reader036.fdocuments.us/reader036/viewer/2022082606/5583f565d8b42afa438b4e2f/html5/thumbnails/6.jpg)
04/13/2023 6
What’s really happening under the covers?
• Reproduced statements similar to original situation:
• User 1 and User 2 hung with enq: TM – contention wait events
![Page 7: Confio oracle enq tm contention wait](https://reader036.fdocuments.us/reader036/viewer/2022082606/5583f565d8b42afa438b4e2f/html5/thumbnails/7.jpg)
04/13/2023 7
What’s really happening under the covers?
• Reviewed V$SESSION:
![Page 8: Confio oracle enq tm contention wait](https://reader036.fdocuments.us/reader036/viewer/2022082606/5583f565d8b42afa438b4e2f/html5/thumbnails/8.jpg)
04/13/2023 8
Reproducing the solution
• Added an index for the foreign key constraint on the SUPPLIER table back to the PRODUCT table
• Re-ran the test case and everything worked fine – No exclusive locks acquired, no hanging– Oracle takes out exclusive locks on the child table (the
PRODUCT table in our example) when a foreign key constraint is not indexed
• Conclusion: unindexed foreign key constraints can cause severe problems!
![Page 9: Confio oracle enq tm contention wait](https://reader036.fdocuments.us/reader036/viewer/2022082606/5583f565d8b42afa438b4e2f/html5/thumbnails/9.jpg)
04/13/2023 9
Sample query to find unindexed foreign key constraints
SELECT * FROM ( SELECT c.table_name, cc.column_name,
cc.position column_position FROM user_constraints c, user_cons_columns ccWHERE c.constraint_name = cc.constraint_nameAND c.constraint_type = 'R' MINUS SELECT i.table_name, ic.column_name,
ic.column_position FROM user_indexes i, user_ind_columns ic WHERE i.index_name = ic.index_name ) ORDER BY table_name, column_position;
![Page 10: Confio oracle enq tm contention wait](https://reader036.fdocuments.us/reader036/viewer/2022082606/5583f565d8b42afa438b4e2f/html5/thumbnails/10.jpg)
04/13/2023 10
With Confio Ignite, You Find Blocks Quickly
• Improve database performance by 65% with Confio Ignite– Installs in minutes– Puts no load on monitored servers– Identify bottlenecks and root causes of blocks like
these in minutes
Download Ignite trial for freewww.confio.com/freetrial