How to write a script to query high-cost SQL on Metalink
This article introduces how to write a script for querying high-cost SQL on Metalink. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
A script for Metalink to find a long and expensive SQL:
Depending on whether the Program column is SQL*PLUS or third-party tools, when doing large operations on business tables, these operations may cause system performance problems.
Know who is doing the operation through machine, and you can kill these session at any time according to the actual situation.
Set line 250
Col ssid format 9999 heading SID
Col opname format a15 TRUNCATE
Col target format a28 TRUNCATE
Col es format 99999.9 Heading "Time | Ran"
Col tr format 99999.90 Heading "Time | Left"
Col pct format 999.90 Heading "PCT"
Col RATE FORMAT a6 truncate Heading "Iswap O | Rate/m"
Col program format a20 TRUNCATE
Col MACHINE format a20 truncate
Select
L.sid ssid
Substr (OPNAME,1,15) opname
Target
Trunc ((sofar/totalwork) * 100) pct
To_char (60*sofar*8192/ (244th 60* (last_update_time-start_time)) / 1024ax 1024Universe 60, '9999.0') Rate
Elapsed_seconds/60 es
Time_remaining/60 tr,PROGRAM,MACHINE
From v$session_longops LMAG Vendor session S
Where time_remaining > 0 AND L.SID=S.SID
Order by start_time
/
This is the end of the script for querying high-cost SQL on Metalink. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.