Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

dbms_workload_repository topnsql Tips

Oracle Database Tips by Donald BurlesonSeptember 26, 2015

Question:  I see the topnsql argument in dbms_workload_repository:

desc dbms_workload_repository

retention IN NUMBER DEFAULT NULL,
interval  IN NUMBER DEFAULT NULL,
topnsql   IN NUMBER DEFAULT NULL,
dbid      IN NUMBER DEFAULT NULL);

What does the topnsql column do?

Answer:  The topnsql is used to specify the number of SQL to collect at each AWR snapshot for each criteria like elapsed time, CPU time, parse calls, shareable memory, and version count.  The topnsql is normally set to a small number like 10, because you only want to see the most current SQL statements.  This SQL information is normally purged after a period of time, after which the SQL source code is no longer needed.
 
begin
dbms_workload_repository.modify_snapshot_settings(
   retention => 7200,
   interval =>60 ,
   topnsql =>10 ,
   dbid => 123661118);
end;
/
  

There are 14 criteria in an AWR report, and Oracle AWR will capture the top-n-SQL for each of these criteria:

1. Elapsed Time (ms)
2. CPU Time (ms)
3. Executions
4. Buffer Gets
5. Disk Reads
6. Parse Calls
7. Rows
8. User I/O Wait Time (ms)
9 Cluster Wait Time (ms)
10. Application Wait Time (ms)
11. Concurrency Wait Time (ms)
12. Invalidations
13. Version Count
14. Sharable Mem(KB)

You can also set threshold for each of the criteria.  Unlike STATSPACK, AWR uses a "Top N" method which defaults to collect the Top-30 SQL statements for each SQL category, If you set statistics_level = "all", AWR will collect the top 100 SQL statements.

The number of SQL statements captured also depends on your statistics_level setting:

- When statistics_level=typical, AWR will capture the topnsql.  Without the topnsql set, the default is to capture 30 SQL statements, for a total of 420 per snapshot.

- When statistics_level=all, AWR will capture the top 100 SQL for each of the criteria (elapsed time, CPU, disk reads, etc.), for a total of 1400 SQL statements per snapshot.

Of course, some SQL statements will appear in more then one category.

 
Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.

 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster