Saturday, April 21, 2018

Report Long Running Queries|Long Active Sessions Script | Oracle On Linux

It's crucial to any DBA to get to know about long running queries that can impact the performance on his/her database environment.
Badly coded reports along with developers' bad habit of using "select *" to navigate data on big tables enforce the DBA to have a kind of an early warning tool to get him aware of such performance threats before it exaggerates.

If you're running Oracle on Linux, then this script is made for you.
Download link:
https://www.dropbox.com/s/a1wn1j1squjf1qx/DBA_BUNDLE2_6Feb2016.tar?dl=0

The use of this script is so easy, the script will run against all instances on the server reporting any active sessions for more than 60 minutes (the default), you can adjust that time by changing the following parameter under THRESHOLDS section to the number of minutes you want:
EXEC_TIME_IN_MINUTES=60        # Report Sessions running longer than N minutes (default is 60 min).

Also, you can control the number of long active session if reached, then the email will be triggered. by using the following parameter:
LONG_RUN_SESS_COUNT=0        # The count of long running sessions, report will not appear unless reached (0 report all long running sessions).

Last, you must provide your good email address in order to get a detailed report of long running queries/active sessions by email:
MAIL_LIST="youremail@yourcompany.com"

This script can be scheduled in the crontab to run every 5/10 minutes.

In the upcoming post, I'll share a script that automatically kills long active sessions connected by specific programs like SQL Developer or Toad. Let's make the life of our beloved developers easy as they always make our life easy :-)

Report Long Running Queries | Long Active Sessions Script (github version):

No comments: