Resource consuming queries.

Dear Experts,

I want to know the resource consuming queries in the database. Is there an easy way to get this.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

select * from v$sqlstats
another option - check current session statistics, resource consumption might not be a single query, but rather a session running lots of queries

-- you can refine or extend the list of statistics to whatever you want by changing the IN clause

  SELECT, ss.VALUE, s.*
    FROM v$session s, v$sesstat ss, v$statname sn
   WHERE ss.statistic# = sn.statistic#
     AND IN ('CPU used by this session', 'redo size', ' session logical reads')  
     AND s.sid = ss.sid
     AND ss.VALUE != 0
ORDER BY s.sid,;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sakthikumarAuthor Commented:
This is good. But how to get Sql in the second query.
use the sql_id  from v$session in the query above


select * from v$sql where sql_id = 'xxxxxxxxx';      where xxxxxxx is whatever sql_id you got from the first query

that will only give you the query that is running right now.

if you have a session running lots and lots of small queries this might not be helpful, because no one query is consuming much, but in total, they are expensive.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.