Pages

Tuesday, January 30, 2024

AWR Report - Wait event "cursor: pin S wait on X"

===========================
General
===========================
Checking the AWR report, the top foreground event is  "cursor: pin S wait on X".
What does it mean?


===========================
Oracle Documentation
===========================
Per Oracle Tech Note Troubleshooting 'cursor: pin S wait on X' waits. (Doc ID 1349387.1)

What is a 'Cursor: pin S wait on X' wait?

A cursor wait is associated with parsing in some form. 
A session may wait for this event when it is trying to get a mutex pin in Share mode but another session is holding the mutex pin on the same cursor object in exclusive.  
Frequently, waits for 'Cursor: pin S wait on X' is a symptom and not the cause.  
There may be underlying tuning requirements or known issues.

Apparently up to Oracle 11, there was a limit to child cursors, which was 1024.
In Oracle 11, this limit does not exists, which can lead to high number of child cursors.

==========================================
Look for a specific SQL that might be responsible for the wait.
==========================================
SELECT * 
FROM DBA_HIST_SNAPSHOT;
To get the snap_id

SELECT sql_id, count(*)
FROM DBA_HIST_ACTIVE_SESS_HISTORY
WHERE snap_id = 31405
  AND event = 'cursor: pin S wait on X'
GROUP BY sql_id
ORDER BY count (*) DESC

6jb4173jbysjp 3526

So one sql_id is responsible for all the  'cursor: pin S wait on X' waits

SELECT * 
FROM V$SQL_TEXT 
WHERE sql_id = '6jb4173jbysjp'

INSERT INTO DEBUG_GEN_W_SDR 
(CDR_ID, PRODUCT_ID, PRODUCT_NAME, SYSTEM_ID, BILLING_TAG, IMSI, MSISDN, IMEI, EVENT_NAME, HOME_COUNTRY_ID, HOME_COUNTRY_NAME, VISITED_COUNTRY_ID, VISITED_COUNTRY_NAME, HOME_NETWORK_ID,HOME_NETWORK_NAME, HOME_PLMN_CODE, VISITED_NETWORK_ID, VISITED_NETWORK_NAME, CLI_IN, CLI_OUT, ORIG_DN, DN_IN, DN_OUT, DN_IN_NOA, REDIRECTION_NUMBER, CALL_TYPE, ROAMING_TYPE, SERVICE_KEY_IN, CURRENT_MSC_GT,SCCP_CALLED_GT, SCCP_CALLING_GT, CALL_END_CLEAR_CAUSE_ID, CALL_END_CLEAR_CAUSE_NAME, CALL_END_NETWORK_CLEAR_CAUSE, SESSION_START_TS, SESSION_END_TS, SESSION_DESC, SESSION_TS_ANSWER, SESSION_TS_DISCONNECT, SESSION_DUR_SEC, EXTERNAL_CALL_REF_NUM, PARAM1, PARAM2, PARAM3,PARAM4,PARAM5, PARAM6, PARAM7, PARAM8, PARAM9, PARAM10, PARAM11, PARAM12, PARAM13, PARAM14, PARAM15, PARAM16, PARAM17, PARAM18, PARAM19, PARAM20, PARAM21, PARAM22, PARAM23, PARAM24,PARAM25, PARAM26, PARAM27, PARAM28, PARAM29, PARAM30, PARAM31,PARAM32,PARAM33,PARAM34,PARAM35, PARAM36, PARAM37, PARAM38, PARAM39, PARAM40, PARAM41, PARAM42, PARAM43, PARAM44) 
VALUES (:1 ,:2 ,:3 ,:4 ,:5 ,:6 ,:7 ,:8 ,:9 ,:10 ,:11 ,:12 ,:13 ,:14 ,:15 ,:16 ,:17 ,:18 ,:19 ,:20 ,:21 ,:22 ,:23 ,:24 ,:25 ,:26 ,:27 ,:28 ,:29 ,:30 ,:31 ,:32 ,:33 ,:34 ,:35 ,:36 ,:37 ,:38 ,:39 ,:40 ,:41 ,:42 ,:43 ,:44 ,:45 ,:46 ,:47 ,:48 ,:49 ,:50 ,:51 ,:52 ,:53 ,:54 ,:55 ,:56 ,:57 ,:58 ,:59 ,:60 ,:61 ,:62 ,:63 ,:64 ,:65 ,:66 ,:67 ,:68 ,:69 ,:70 ,:71 ,:72 ,:73 ,:74 ,:75 ,:76 ,:77 ,:78 ,:79 ,:80 ,:81 ,:82 ,:83 ,:84 ,:85 )

This SQL is using bind variable, seems that there is nothing wrong with that...

SELECT version_count, executions, parse_calls, parsing_schema
FROM V$SQLAREA 
WHERE sql_id = '6jb4173jbysjp'

version_count = 2717
executions = 5646
parse_calls = 1631
parsing_schema_name = MY_USER

So the issue is the big number of version_count.
Why did this happen?


===========================
High number of cusror version count
===========================
This is a very nice post

   In short, when java application is doing UPDATE or INSERT with a column having NULL value, it does not grantee that the datatype for the NULL value parameter, would be the same in all the executions.
   To grantee that, application must set parameter to a specific datatype, in addition to setting value to NULL.
   In case there are many such NULL values columns, the combinations number would be high, leading to the high number of child cursors.
   Changing the data type of a bind variable invalidates the child cursor (“bind mismatch”).

   In detail...
   jdbs driver by default is using setNull.NULL. 
   In this case the setter method will not use the data type of the field in the table. 
   Instead, the default is VARCHAR2 is used.
   If in another execution a value is passed, the setter would use the data type of the field in the table. 
   In theory, setting over 30 numeric values to null and non-null in an alternating matter, creates 2^30 child cursors.

   The solution would be set the bind variable to the correct datatype in addition to setting value to NULL.

===========================
V$SQL_SHARED_CURSOR 
===========================
   To see child cursors:
SELECT * FROM V$SQL_SHARED_CURSOR 
WHERE address LIKE 'f3g84j69n0tjh%'

This table has many types, for which cursor could not be shared, and child cursors were created.

DESC V$SQL_SHARED_CURSOR
Name                          Type              Nullable 
----------------------------- ----------------- -------- 
SQL_ID                        VARCHAR2(13 BYTE) Y                         
ADDRESS                       RAW(8)            Y                         
CHILD_ADDRESS                 RAW(8)            Y                         
CHILD_NUMBER                  NUMBER            Y                         
UNBOUND_CURSOR                VARCHAR2(1 BYTE)  Y                         
SQL_TYPE_MISMATCH             VARCHAR2(1 BYTE)  Y                         
OPTIMIZER_MISMATCH            VARCHAR2(1 BYTE)  Y                         
OUTLINE_MISMATCH              VARCHAR2(1 BYTE)  Y                         
STATS_ROW_MISMATCH            VARCHAR2(1 BYTE)  Y                         
LITERAL_MISMATCH              VARCHAR2(1 BYTE)  Y                         
FORCE_HARD_PARSE              VARCHAR2(1 BYTE)  Y                         
EXPLAIN_PLAN_CURSOR           VARCHAR2(1 BYTE)  Y                         
BUFFERED_DML_MISMATCH         VARCHAR2(1 BYTE)  Y                         
PDML_ENV_MISMATCH             VARCHAR2(1 BYTE)  Y                         
INST_DRTLD_MISMATCH           VARCHAR2(1 BYTE)  Y                         
SLAVE_QC_MISMATCH             VARCHAR2(1 BYTE)  Y                         
TYPECHECK_MISMATCH            VARCHAR2(1 BYTE)  Y                         
AUTH_CHECK_MISMATCH           VARCHAR2(1 BYTE)  Y                         
BIND_MISMATCH                 VARCHAR2(1 BYTE)  Y   
and much more...

===========================
Workaround
===========================
Flush the shared pool for the specific statement, using DBMS_SHARED_POOL.purge.

Execution of DBMS_SHARED_POOL.PURGE needs an EXECUTE permission from sysdba.

SQL> SELECT address, hash_value, version_count  FROM V$SQLAREA WHERE sql_id LIKE 'f3g84j69n0tjh%';

ADDRESS          HASH_VALUE VERSION_COUNT
---------------- ---------- -------------
000000009F8E4970 2470471216           102

SQL> exec DBMS_SHARED_POOL.PURGE ('000000009F8E4970, 2470471216', 'C');

PL/SQL procedure successfully completed.

SQL> SELECT address, hash_value, version_count  FROM V$SQLAREA WHERE sql_id LIKE 'f3g84j69n0tjh%';

no rows selected



Or via PL/SQL block:

CREATE OR REPLACE PROCEDURE purge_sql_sp AS

  v_sql_id          V$SQLAREA.sql_id%TYPE := '';
  v_sql_address     V$SQLAREA.address%TYPE := '';
  v_hash_value      V$SQLAREA.hash_value%TYPE := '';

BEGIN

  SELECT sql_id INTO v_sql_id
    FROM V$SQLAREA
   WHERE sql_text LIKE 'MERGE into SOME_TABLE%';

  --EXECUTE IMMEDIATE 'SELECT address, hash_value FROM V$SQLAREA 
WHERE sql_id = ''someSQLIDfoo''' INTO v_sql_address,v_hash_value;

  EXECUTE IMMEDIATE 'SELECT address, hash_value FROM V$SQLAREA WHERE sql_id = '''||v_sql_id||'''' INTO v_sql_address,v_hash_value;

  DBMS_SHARED_POOL.purge (v_sql_address||','||v_hash_value||','C');

END;

The SQL ID should remain the same, so this piece of code could be wrapped into a scheduled job, as needed.

Check status:
SELECT 'SPE7' as source_db,  
       TO_CHAR(begin_interval_time,'YYYYMMDD hh24:mi'), 
       sql_id,  
       executions_delta, 
       loaded_versions, 
       invalidations_delta, 
       parse_calls_delta, 
       disk_reads_delta
  FROM DBA_HIST_SQLSTAT, 
       DBA_HIST_SNAPSHOT 
 WHERE sql_id = '71bmcyg2f5td0'
   AND DBA_HIST_SQLSTAT.snap_id = DBA_HIST_SNAPSHOT.snap_id
ORDER BY 2 DESC;

Thursday, January 25, 2024

RMAN-06091 no channel allocated for maintenance

Issue
During rman backup, there is an error:
RMAN-00571: ==============================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS 
RMAN-00571: ==============================================
RMAN-03002: failure of delete command at 18/01/2021 22:04:21
RMAN-06091: no channel allocated for maintenance (of an appropriate type)

The error is coming from delete obsolete archive logs and backups.

Solution

A way to see expired backups
RMAN> CROSSCHECK BACKUP;
RMAN> DELETE EXPIRED BACKUP;
Are you sure? YES

In case of disk backup:
To delete obsolete backup sets :
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE TYPE DISK;
To delete obsolete:
RMAN> CROSSCHECK ARCHIVELOG ALL;
RMAN> DELETE OBSOLETE DEVICE TYPE DISK; 

To delete expired:
RMAN> DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
RMAN> DELETE NOPROMPT EXPIRED BACKUPSET;


In case of SBT backup:
To delete obsolete backup sets of SBT type:
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE TYPE SBT;
RMAN> CROSSCHECK ARCHIVELOG ALL;
RMAN> DELETE OBSOLETE DEVICE TYPE SBT; 


But this step failed!
allocate channel for maintenance device type 'SBT_TAPE'; 
ORA-27211 Failed to load media management library

Note:
I failed to understand how SBT type backup pieces were created on the system in the first place.
All the scheduled scripts work only with DISK type!
All the SBT type backup pieces were expired.
Seems they were created, but then failed to be deleted with the default script that uses DISK type.
To delete them manually, I had to allocate a dummy path, to be able to delete the SBT type backupsets.

--This will allow to work with SBT type
allocate channel for maintenance device type sbt parms 'SBT_LIBRARY=oracle.disksbt, ENV=(BACKUP_DIR=/tmp)';

--This will give list of all backupsets
LIST BACKUPSET;

--This will give info for backupsets 8840
LIST BACKUPSET 8840;

The output gives:
Backupset 8840 is a SBT_TYPE, and it has no backuppieces.

--It will mark it as EXPIRED, and now it can be deleted
CROSSCHECK BACKUPSET 8840;

--Delete the backupset without the "YES" approval
DELETE NOPROMPT BACKUPSET 8840;


==========================================
crontab task to delete old SBT and Disk backups
==========================================

/backup/ora_online/scripts/rnam_del_old_backups.sh
#!/bin/bash

./etc/profile > /dev/null 2>/dev/null
./etc/sh/orash/oracle_login.sh igt
. $BACKUP_ROOT/internal/backupFunctions.sh

WORK_DIR=/backup/ora_online/scripts
LOGFILE=/backup/ora_online/scripts/rman_del_old_backups.log

write_to_log() {
 echo $1
 echo $1 >> $LOGFILE
}

#main()
RUN_DATE=`date +"%Y%m%d"_"%H%M%S"`
write_to_log " "
write_to_log "============================="
write_to_log "Running at $RUN_DATE"
write_to_log "============================="

write_to_log "Starting Clean SBT Backups"
rman target / << zZ >> $LOGFILE
allocate channel for maintenance device type SBT_TAPE PARMS 'SBT_LIBRARY=oracle.disksbt, ENV=(BACKUP_DIR=/tmp)';
LIST BACKUPSET;
CROSSCHECK BACKUPSE;
DELETE NOPROMPT EXPIRED BACKUPSET;
RELEASE CHANNEL;
EXIT;
zZ

write_to_log "Starting Clean Disk Backups"
rman target / << zZ >> $LOGFILE
allocate channel for maintenance device type disk;
DELETE NOPROMPT ACRHIVELOG ALL BACKED UP 1 TIMES TO DEVICE TYPE DISK;
DELETE NOPROMPT COPY OF ACRHIVELOG ALL COMPLETED BEFORE 'SYSDATE-2';
DELETE NOPROMPT OBSOLETE REDUNDANCE = 1;
RELEASE CHANNEL;
EXIT;
zZ

write_to_log "Finished Clean Backups"



crontab task to delete old directories

/backup/ora_online/scripts/clean_old_backups.sh
#!/bin/bash

WORK_DIR=/backup/ora_online/scripts
BACKUP_DIR=/backup/ora_online
TARGET_DIR=/backup/ora_online/for_backup
LOGFILE=${WORK_DIR}/clean_old_backups.log

write_to_log() {
 echo $1
 echo $1 >> $LOGFILE
}

#main()
RUN_DATE=`date +"%Y%m%d"_"%H%M%S"`
write_to_log " "
write_to_log "============================="
write_to_log "Running at $RUN_DATE"
write_to_log "============================="

for d in `find /backup/ora_online -maxdepth 1 -type d -name "20*"`
do
 write_to_log "Handling Directory $d"
 mv $d ${TARGET_DIR}/
done

directories=`ls -1 ${TARGET_DIR} | grep 20 | wc -l`
while [[ $directories -gt 2 ]];
do
 del_dir=`ls -1 ${TARGET_DIR} | grep 20 | sort | head -1`
 write_to_log "Deleting Directory ${TARGET_DIR}/$del_dir"
 rm -r ${TARGET_DIR}/$del_dir
 directories=`ls -1 ${TARGET_DIR} | grep 20 | wc -l`
done

Sunday, January 21, 2024

Oracle Security Patches. CVE, Theory and example, for on Golden Gate

======================
What is CVE
======================

CVE - Common Vulnerabilities and Exposures
It is a list of publicly disclosed information security vulnerabilities and exposures.
CVE was launched in 1999 by the MITRE corporation to identify and categorize vulnerabilities in software and firmware. 

CVE provides a free dictionary for organizations to improve their cyber security. 
MITRE is a nonprofit that operates federally funded research and development centers in the United States.

Vulnerabilities vs. Exposures
A vulnerability is a weakness that can be exploited in a cyber attack to gain unauthorized access to or perform unauthorized actions on a computer system. 
Vulnerabilities can allow attackers to run code, access system memory, install different types of malware and steal, destroy or modify sensitive data.
An Exposure is a mistake that gives an attacker access to a system or network. 
Exposures can lead to data breaches, data leaks, and personally identifiable information (PII) being sold on the dark web.

What is the Goal of CVE?
The goal of CVE is to make it easier to share information about known vulnerabilities so that cybersecurity strategies can be
 updated with the latest security flaws and security issue.
CVE does this by creating a standardized identifier for a given vulnerability or exposure. 
CVE identifiers (also called CVE names or CVE numbers) allow security professionals to access information about specific cyber threats 
across multiple information sources using the same common name.
For example, UpGuard is a CVE compatible product, and its reports reference CVE IDs. 
This allows you to find fix information on any CVE compatible vulnerability database.

CVSS - Common Vulnerability Scoring System
CVSS is a set of open standards for assigning a number to a vulnerability to assess its severity. 
CVSS scores are used by the NVD, CERT, UpGuard and others to assess the impact of a vulnerability.
A CVSS score ranges from 0.0 to 10.0. The higher the number the higher degree of security severity.

Who Sponsors CVE?
CVE is sponsored by the U.S. Department of Homeland Security (DHS) Cybersecurity and Infrastructure Security Agency (CISA) and US-CERT.

CNA - CVE Numbering Authorities
CNAs are organizations that identify and distribute CVE id numbers to researchers and vendors for inclusion in public announcements of new vulnerabilities. 
CNAs include software vendors, open source projects, coordination centers, bug bounty service providers and research groups.
CNAs are a federated systems that helps identify vulnerabilities and assigns them an ID without directly involving MITRE which is the primary CNA.
There are currently 104 CNAs in 18 countries including many household names like Microsoft, Adobe, Apple, Cisco, Google, Hewlett Packard Enterprise, Huawei, IBM, Intel, Mozilla, Oracle, Red Hat, Siemens, Symantec, VMWare, Atlassian, Autodesk, Cloudflare, Elastic, GitHub, Kubernetes, Netflix and Salesforce. 

======================
Oracle CPU
======================
CPU - Critical Patch Update

A Critical Patch Update is a collection of patches for multiple security vulnerabilities. 
These patches address vulnerabilities in Oracle code and in third-party components included in Oracle products. 

These patches are usually cumulative, but each advisory describes only the security patches added since the previous Critical Patch Update Advisory. 

Thus, prior Critical Patch Update advisories should be reviewed for information regarding earlier published security patches. 

Refer to “Critical Patch Updates, Security Alerts and Bulletins” for information about Oracle Security advisories.


======================
How to Start?
======================
Oracle releases it 
Critical Patch Update periodically

For Example:
Critical Patch Update for April 2023 Documentation Map (Doc ID 2921643.1)

It has a list of Critical Patches per product
For Golden Gate:
CVE-2022-42003   Oracle Database (Oracle GoldenGate) [5757] Oracle Critical Patch Update April 2023

Following Oracle Critical Patch Update April 2023 link for correct Golden gate version:
Oracle GoldenGate, versions prior to 19.1.0.0.230418, prior to 21.10.0.0.0 -> Oracle GoldenGate Risk Matrix
Oracle Critical Patch Update Advisory - April 2023

This Critical Patch Update contains 433 new security patches across the product families listed below. But now focus on Golden Gate.

Oracle GoldenGate Risk Matrix
This Critical Patch Update contains 2 new security patches for Oracle GoldenGate
CVE-2022-42003 Oracle GoldenGate

Oracle GoldenGate Risk Matrix
This Critical Patch Update contains 2 new security patches, plus additional third party patches noted below, for Oracle GoldenGate.  1 of these vulnerabilities may be remotely exploitable without authentication, i.e., may be exploited over a network without requiring user credentials.  The English text form of this Risk Matrix can be found
CVE-2022-42003
Oracle GoldenGate
Prior to 19.1.0.0.230418, Prior to 21.10.0.0.0

Searching for Golden gate Critical Patch Update (CPU) Apr 2023:
Critical Patch Update (CPU) Program Apr 2023 Patch Availability Document (DB-only) (Doc ID 2923348.1)

section 3.1.9 Oracle GoldenGate, for Golden gate 19.1 for oracle version 12.2

Oracle GoldenGate 19.1.0.0.230418 for Oracle 12c Patch 35275313 or later
Search for Patch 35275313:
 
Patch 35275313: Oracle GoldenGate 19.1.0.0.230418 for Oracle 12c: This Patch is Obsolete. and was replaced by patch 35326271
 
So next it to download an apply 
patch 35326271


Minimum Opatch version for Oracle GoldenGate 19.1.0.0.230418 opatches is v12.2.0.1.36. 
The Oracle OPatch downloads can be found at Patch 6880880
=================

======================
How to get Oracle and Golden Gate version
======================
/software/ogg/191>% ./ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 19.1.0.0.1 OGGCORE_19.1.0.0.0_PLATFORMS_190524.2201_FBO
Linux, x64, 64bit (optimized), Oracle 12c on May 25 2019 12:43:32
Operating system character set identified as UTF-8.

SQL> SELECT * FROM V$VERSION;
BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
PL/SQL Release 12.2.0.1.0 - Production
CORE    12.2.0.1.0      Production
TNS for Linux: Version 12.2.0.1.0 - Production
NLSRTL Version 12.2.0.1.0 - Production



/software/oracle/122/OPatch>% /software/oracle/122/OPatch/opatch version
OPatch Version: 12.2.0.1.17
OPatch succeeded.


uname -a
Linux 3.10.0-1160.71.1.el7.x86_64 #1 SMP Wed Jun 15 08:55:08 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Red Hat Enterprise Linux Server release 7.9 (Maipo)

Monday, January 15, 2024

ALTER INDEX REBUILD ONLINE in Standard Edition Oracle (SE)

Option A
ALTER INDEX IX01 REBUILD ONLINE = 
ALTER INDEX 
IX01 COALESCE; + ALTER INDEX IX01 SHRINK SPACE;

Option B
Get DDL
SET LONG 1000
SET PAGESIZE 0
SET LINESIZE 400
COL DDL_CMD FOR A400 WORD_WRAP
SET FEEDBACK OFF
SET HEADING OFF

SELECT DBMS_METADATA.get_dependent_ddl('INDEX','GA_W_COUNTERS_HISTORY', 'MY_USER') AS DDL_CMD FROM DUAL;

Drop and Create the Index using the generated DDL.


Automate the process
crontab 
1 6 * * * bash -l /software/oracle/oracle/scripts/rebuild_ix/rebuild_ix.sh

rebuild_ix.sh
#!/bin/bash

WORK_DIR=/software/oracle/oracle/scripts/rebuild_ix
. /etc/sh/orash/oracle_login.sh igt

ORACLE_SID=igt
ORACLE_BASE=/software/oracle
ORACLE_HOME=/software/oracle/121

cd ${WORK_DIR}
sqlplus / as sysdba @rebuild_ix.sql

rebuild_ix.sql
ALTER INDEX USER_A.INDEX_A COALESCE;
ALTER INDEX USER_A.INDEX_A SHRINK SPACE;

ALTER INDEX USER_B.INDEX_B COALESCE;
ALTER INDEX USER_B.INDEX_B SHRINK SPACE;

EXIT;


Statspack Report Idle Events

When running spreport.sql top events are idle event, no I/O, very little CPU...

To fix the issue in the report, need to sync idle events in STATS$IDLE_EVENT




 Snapshot       Snap Id     Snap Time      Sessions Curs/Sess Comment
~~~~~~~~    ---------- ------------------ -------- --------- --------
Begin Snap:      42251 15-Jan-24 10:00:06      233       3.3
  End Snap:      42252 15-Jan-24 11:00:11      232       3.3
   Elapsed:      60.08 (mins) Av Act Sess:       1.0
   DB time:      61.11 (mins)      DB CPU:      60.82 (mins)

When running perfstat, only idle event appear as top time consumets.
   
Top 5 Timed Events                                                    Avg %Total
~~~~~~~~~~~~~~~~~~                                                  

Event                             Waits    Time (s)   (ms)   Time
-------------------------- ------------ ----------- ------ ------
LGWR worker group idle            6,575       7,202   1095   33.2
AQPC idle                           121       3,631  30005   16.7
CPU time                                      3,619          16.7
heartbeat redo informer           3,604       3,605   1000   16.6
lreg timer                        1,260       3,604   2860   16.6
    -------------------------------------------------------------

There were idle events that have been introduced in recent versions, which are not listed in STATS$IDLE_EVENT

To sync the idle events list:


SELECT COUNT(*) FROM STATS$IDLE_EVENT;
135

SELECT COUNT(*) FROM V$EVENT_NAME where wait_class='Idle';
121

desc STATS$IDLE_EVENT
 Name                                      Null?    Type
 ----------------------------------------- -------- -----------------
 EVENT                                     NOT NULL VARCHAR2(64 CHAR)

desc  V$EVENT_NAME
 Name                                      Null?    Type
 ----------------------------------------- -------- -----------------
 EVENT#                                             NUMBER
 EVENT_ID                                           NUMBER
 NAME                                               VARCHAR2(64)
 PARAMETER1                                         VARCHAR2(64)
 PARAMETER2                                         VARCHAR2(64)
 PARAMETER3                                         VARCHAR2(64)
 WAIT_CLASS_ID                                      NUMBER
 WAIT_CLASS#                                        NUMBER
 WAIT_CLASS                                         VARCHAR2(64)
 DISPLAY_NAME                                       VARCHAR2(64)
 CON_ID                                             NUMBER

SELECT NAME FROM V$EVENT_NAME WHERE wait_class='Idle' order by 1;

NAME
----------------------------------------------------------------
AQ Cross Master idle
AQ: 12c message cache init wait
AQPC idle
ASM background timer
Backup Appliance Comm SGA setup wait
Backup Appliance Servlet wait
Backup Appliance Surrogate wait
Backup Appliance waiting for work
Backup Appliance waiting restore start
DIAG idle wait
EMON slave idle wait
Emon coordinator main loop
Emon slave main loop
GCR sleep
HS message to agent
IORM Scheduler Slave Idle Wait
JOX Jit Process Sleep
JS external job
LGWR real time apply sync
LGWR worker group idle
LNS ASYNC archive log
LNS ASYNC dest activation
LNS ASYNC end of log
LogMiner builder: branch
LogMiner builder: idle
LogMiner client: transaction
LogMiner preparer: idle
LogMiner reader: log (idle)
LogMiner reader: redo (idle)
LogMiner: activate
LogMiner: find session
LogMiner: internal
LogMiner: other
LogMiner: reset
Logical Standby Apply Delay
MRP redo arrival
OFS idle
PING
PL/SQL lock timer
PX Deq Credit: need buffer
PX Deq Credit: send blkd
PX Deq: Execute Reply
PX Deq: Execution Msg
PX Deq: Index Merge Close
PX Deq: Index Merge Execute
PX Deq: Index Merge Reply
PX Deq: Join ACK
PX Deq: Metadata Update
PX Deq: Msg Fragment
PX Deq: Parse Reply
PX Deq: Table Q Normal
PX Deq: Table Q Sample
PX Deq: Txn Recovery Reply
PX Deq: Txn Recovery Start
PX Deq: kdcph_mai
PX Deq: kdcphc_ack
PX Deque wait
PX Idle Wait
REPL Apply: txns
REPL Capture/Apply: RAC AQ qmn coordinator
REPL Capture/Apply: messages
REPL Capture: archive log
SGA: MMAN sleep for component shrink
SQL*Net message from client
SQL*Net vector message from client
SQL*Net vector message from dblink
Sharded  Queues : Part Maintenance idle
Space Manager: slave idle wait
Streams AQ: deallocate messages from Streams Pool
Streams AQ: delete acknowledged messages
Streams AQ: emn coordinator idle wait
Streams AQ: load balancer idle
Streams AQ: qmn coordinator idle wait
Streams AQ: qmn slave idle wait
Streams AQ: waiting for messages in the queue
Streams AQ: waiting for time management or cleanup tasks
VKRM Idle
VKTM Init Wait for GSGA
VKTM Logical Idle Wait
WCR: replay client notify
WCR: replay clock
WCR: replay paused
auto-sqltune: wait graph update
cell worker idle
class slave wait
cmon timer
dispatcher timer
fbar timer
gcs remote message
ges remote message
gopp msg
heartbeat monitor sleep
heartbeat redo informer
i/o slave wait
imco timer
iowp file id
iowp msg
jobq slave wait
lreg timer
netp network
parallel recovery control message reply
parallel recovery coordinator idle wait
parallel recovery coordinator waits for slave cleanup
parallel recovery slave idle wait
parallel recovery slave next change
pipe get
pmon timer
pool server timer
process in prespawned state
rdbms ipc message
recovery merger idle wait
recovery receiver idle wait
recovery sender idle wait
shared server idle wait
simulated log write delay
single-task message
smon timer
virtual circuit next request
wait for unread message on broadcast channel
wait for unread message on multiple broadcast channels
watchdog main loop


SELECT name FROM V$EVENT_NAME WHERE wait_class='Idle' 
MINUS
SELECT event FROM STATS$IDLE_EVENT;
order by 1

NAME
---------------------------------------------------------------------
AQ Cross Master idle
AQ: 12c message cache init wait
AQPC idle                             => top perfstat wais
Backup Appliance Comm SGA setup wait
Backup Appliance Servlet wait
Backup Appliance Surrogate wait
Backup Appliance waiting for work
Backup Appliance waiting restore start
Emon coordinator main loop
Emon slave main loop
LGWR worker group idle       => top perfstat wais
OFS idle
PL/SQL lock timer
REPL Apply: txns
REPL Capture/Apply: RAC AQ qmn coordinator
REPL Capture/Apply: messages
REPL Capture: archive log
Sharded  Queues : Part Maintenance idle
Streams AQ: load balancer idle
gopp msg
heartbeat redo informer
imco timer
iowp file id
iowp msg
lreg timer
netp network
parallel recovery coordinator idle wait
process in prespawned state
recovery merger idle wait
recovery receiver idle wait
recovery sender idle wait
virtual circuit next request


SQL>INSERT INTO STATS$IDLE_EVENT
SELECT name FROM V$EVENT_NAME WHERE wait_class='Idle'
MINUS
SELECT event FROM STATS$IDLE_EVENT;

32 rows created.

SQL> commit;

Commit complete.

Now, when running spreport.sql top events are without idle events.

Top 5 Timed Events                                                    Avg %Total
~~~~~~~~~~~~~~~~~~                                                  Event                           Waits    Time (s)   (ms)   Time
-------------------------- ------------ ----------- ------ ------
CPU time                          3,619          99.2
db file async I/O submit          2,058          11      5     .3
db file sequential read          59,240           4      0     .1
log file parallel write           6,568           4      1     .1
oracle thread bootstrap             179           4     20     .1
    -------------------------------------------------------------