Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Top 5 queries - One of them is sequence.nextval from dual !!!!!

VIRUNov 3 2011 — edited Nov 3 2011
Hi All,
I am using ORACLE DATABASE 11g and Oracle Linux 5.

My intentions are to get the top resource consuming or time consuming queries from database in the particular time frame. I formed the below query to get the same :-
 select a.SQL_FULLTEXT,
             s.module,
             s.cpu_time_total / 1000000,
             s.iowait_total / 1000000,
             s.fetches_total,
             s.sorts_total,
             s.executions_total,
             s.loads_total,
             s.disk_reads_total /
             DECODE(s.executions_total, 0, 1, s.executions_total) reads_per_execution,
             s.disk_reads_total,
             s.direct_writes_total / 1024,
             s.buffer_gets_total / 1204,
             s.rows_processed_total,
             s.elapsed_time_total / 1000000,
             s.apwait_total / 1000000,
             s.ccwait_total / 1000000,
             s.plsexec_time_total / 1000000,
             s.javexec_time_total / 1000000
        from DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT h, v$sqlarea a
       where s.parsing_schema_name = 'ST'
         and s.executions_total != 0
         and s.snap_id = h.snap_id
         and a.SQL_ID = s.sql_id
         and h.begin_interval_time > '03-NOV-11 09.30.00.000 AM'
         and h.end_interval_time < ''03-NOV-11 12.30.59.999 PM'
         and rownum <= 5
       order by 15 desc;
I assume that above query will give me top 5 sql or pl/sql queries which are consuming most resource or time. Please correct me if am wrong with the query.

The surprising fact is that I got the below query as the top most resource consuming query :-
SELECT REF_SEQ.NEXTVAL AS VAL FROM DUAL
I searched for all the code in the database and I was not able to find this line in any code. The fact is that this query should not take more than 1 second as we know that sequence nextval from dual table is very fast so, how can i get this as resource consuming query.

The output is as follows :- ( I have modified the output to show all the facts in detail. Here you can see that it shows the execution time as 10.002467 Seconds. In real this will get execute in less than a second.)
MODULE NAME := Banking
TOTAL CPU TIME := 8.299744 Seconds.
TOTAL IO WAIT TIME := .915287 Seconds.
TOTAL RECORDS FETCHED := 41128 Rows.
SORT OPERATION(S) := 0
TOTAL NO. OF EXECUTION(s) := 41128 Times.
TOTAL NO. OF TIME(S) OBJECT/QUERY LOADED/RELOADED := 5
DATA READ PER EXECUTION := .002139661544446605718731764248200739155806 KB.
TOTAL DISK READS := 88 KB.
TOTAL DISK WRITES := 0 KB.
TOTAL BUFFER READS := 4.92441860465116279069767441860465116279 KB.
TOTAL NO. OF ROW(S) PROCESSED := 41128
TOTAL EXECUTION TIME FOR ONE TRANSACTION := 10.002467 Seconds.
APPLICATION WAIT TIME := 0 Seconds.
CONCURRENCY WAIT TIME := .344575 Seconds.
PL/SQL EXECUTION TIME := 0 Seconds.
JAVA EXECUTION TIME := 0 Seconds.
Please guide me for this method. How to understand the presence of this sequence.nextval query here.
The base requirement is I want a query which will give me top 5 resource/time consuming queries. I have took the help of AWR views in my logic. If you have any better idea let me know.

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 1 2011
Added on Nov 3 2011
6 comments
1,323 views