Script: Inactive Parallel QC Holding Parallel Processes
Working on a data warehouse system can be quite challenging, as I mentioned in the post from yesterday. One of the things we need to take care of is the amount of parallel processes that are in used at all times. Yesterday I wrote about how to locate downgraded sessions. Today we will look at another aspect – who “steals” parallel processes and what can we do to solve it.
One of the biggest thieves of parallel processes in a data warehouse environment are actually developers and DBAs. Sometime, while developing or just handling the system, DBAs run queries in GUI tools (TOAD, PL/SQL Developer, SQL Developer). That for itself isn’t a big deal, but those tools have a common feature. Instead of returning the entire data set, it sometimes return only a few records (the number depends on the tool). In that case, the cursor is being kept open and is waiting for then next fetch or until different query is ran. While waiting, the parallel processes are being reserved for that query, but the query coordinator is marked as Idle.
If there are couple of DBAs running those queries from multiple windows and they “forget” their queries (because sometime they run for very long) – that becomes a problem: “real” application queries are being downgraded causing the mess I described yesterday.
To solve that, we created the following query. We actually took that query and wrapped it with shell script to automatically kill the session, but let’s keep it to the basic query we used.
with curr_sessions as ( SELECT ROUND(BITAND(s.ownerid, 65535)) parent_session_sid, s.sid, s.status, s.sql_id, UPPER(s.program) program FROM v$session s, v$process p WHERE ((s.username IS NOT NULL) AND (NVL(s.osuser, 'x') <> 'SYSTEM') AND (s.TYPE <> 'BACKGROUND')) AND (p.addr(+) = s.paddr)) select distinct a.sid parent, b.sid child, a.status status_p, b.status status_c, a.program, a.sql_id from curr_sessions a join curr_sessions b on a.sid = b.parent_Session_sid and a.status = 'INACTIVE' and a.program in ('TOAD.EXE') order by 1;
Please note – we only killed “TOAD.EXE” program, because this is what the DBAs are using there.
Leave a ReplyWant to join the discussion?
Feel free to contribute!