The PGA_ALLOCATED column in ASH records the amount of PGA memory consumed by the session at the time the sample was taken, so if PGA memory usage is excessive, the following query can identify the offending SQL statements:

SELECT username,
       module,
       sql_id,
       TRUNC(MAX(pga_allocated) / 1024 / 1024) AS pga_allocated_mb
FROM   dba_hist_active_sess_history a,
       dba_users u
WHERE  trunc(sample_time) = trunc(sysdate) - 1
  AND  u.user_id = a.user_id
  AND  u.username NOT IN ('SYS', 'DBSNMP')
GROUP BY username, module, sql_id
ORDER BY pga_allocated_mb DESC
FETCH FIRST 10 ROWS ONLY;

Another useful column in ASH is TEMP_SPACE_ALLOCATED which indicates the temporary tablespace consumed by the session at the time the sample was taken, you can easily modify the query to identify the top consumers of temporary tablespace.

4 responses to “Identifying Top Entities by ASH (Part 4/5): Top PGA or Temp Space Consumers”

Leave a comment

I’m Yuan

Welcome to the blog of a performance maven in Oracle & MySQL. Feel free to contact me to share and discuss database knowledge.

My 20 Oracle Certifications

A screenshot from certview.oracle.com

My Book

MySQL 8.0 Operations and Optimization

Let’s connect