when update statemetns are running longner time

 1. Identify the SID/Session Running the UPDATE                                                                                                                                                                                                                                                                      Use SQL to locate the active session:

SELECT s.sid, s.serial#, s.username, s.status, s.program, q.sql_id, q.sql_text FROM v$session s JOIN v$sql q ON s.sql_id = q.sql_id WHERE s.username IS NOT NULL AND s.sql_id = (SELECT sql_id FROM v$session WHERE sid = &your_sid);

If you don’t know the SID:

SELECT sid, serial#, sql_id, blocking_session, event, wait_class FROM v$session WHERE status='ACTIVE' AND command = 3; -- UPDATE command

2. Check What the Session Is Waiting On

Wait events explain why it's slow:

SELECT sid, event, wait_class, seconds_in_wait FROM v$session WHERE sid = &sid;

Typical causes:

  • enq: TX – row lock contention → waiting for row locks

  • db file sequential read / scattered read → slow IO

  • buffer busy waits

  • log file sync → redo/commit bottleneck

  • read by other session → undo read due to consistent read


3. Check for Blocking Sessions (Locks)

Major cause of slow updates is locking:

SELECT a.sid blocker_sid, b.sid blocked_sid, a.username blocker_user, b.username blocked_user FROM v$session a JOIN v$session b ON a.sid = b.blocking_session ORDER BY a.sid;

Or:

SELECT * FROM dba_blockers; SELECT * FROM dba_waiters;

If the update is waiting on a row lock, this will reveal the blocker.


4. Examine Execution Plan

Look at the plan of the UPDATE's associated SELECT:

SELECT * FROM table(dbms_xplan.display_cursor('&SQL_ID'));

Check for:

  • Full table scans on large tables

  • Missing indexes on WHERE clause columns

  • Inefficient join methods

  • Filters not pushed down


5. Check Undo & Redo Usage

Mass updates consume UNDO and REDO heavily.

Undo Retention Issues:

SELECT used_urec, used_ublk FROM v$transaction;

Redo Log Bottleneck:

SELECT event, total_waits, time_waited FROM v$system_event WHERE event LIKE 'log file%';

If log file sync or log file switch is high → redo bottleneck.


6. Check Segment Statistics

Slow due to hot blocks or high I/O:

SELECT * FROM v$segment_statistics WHERE owner = 'YOUR_SCHEMA' AND object_name = 'YOUR_TABLE' AND statistic_name IN ('logical reads', 'physical reads', 'buffer busy waits');

7. Analyze Table & Index Fragmentation

Check if stats are outdated:

SELECT last_analyzed FROM dba_tables WHERE table_name = 'YOUR_TABLE';

If very old, gather stats:

EXEC dbms_stats.gather_table_stats('SCHEMA', 'TABLE', cascade => TRUE);

8. Parallel Execution / TEMP Usage

Big updates may spill to TEMP:

SELECT tablespace, used_blocks, free_blocks FROM v$temp_space_header;

Or:

SELECT sid, sql_id, temp_space_used FROM v$sort_usage;

9. Check AWR/ASH Reports (Best Insight)

Generate ASH report for the hour:

@$ORACLE_HOME/rdbms/admin/ashrpt.sql

Or AWR:

@$ORACLE_HOME/rdbms/admin/awrrpt.sql

Look for:

  • Top SQL by elapsed time

  • I/O bottlenecks

  • Contention (TX lock, buffer busy, gc waits in RAC)


10. RAC-Specific Checks (If applicable)

Check if the UPDATE is slow due to Global Cache (gc) Waits:

SELECT event FROM v$session WHERE sid = &sid;

If you see:

  • gc buffer busy acquire

  • gc current request

It’s a RAC hotspot issue.


🎯 Summary: Typical Root Causes of Slow UPDATE

CauseHow to ConfirmFix
Row lock contentionTX lock, blocking sessionKill blocker, improve app logic
Missing indexesEXECUTION PLAN shows FTSAdd index
High I/OSequential/scattered readsTune storage, caching
Outdated statslast_analyzed oldGather stats
Redo bottlenecklog file sync highIncrease redo log size
RAC GC contentiongc waitsCache affinity, partitioning
Massive undo generationhigh UNDO usageBreak into batches

If you want, I can also help you:
✅ Interpret a specific SQL_ID
✅ Read the AWR report you have
✅ Suggest index changes for the UPDATE
Just paste the SQL or SQL_ID

{fullwidth)

Comments

Popular posts from this blog

MY NOTEPAD

Oracle OEM Holistic Patch

Upgrade Oracle 19c DB to 21c using Auto Upgrade utility inprogress