How to measure performance of query in oracle

Cshah picture Cshah · Aug 21, 2009 · Viewed 40.4k times · Source

I'm new to Oracle db. I have 2 queries which return the same result set. I want to measure the performance of each of them and choose the better one. How do I do that using Oracle SQL developer? I remember reading that certain tools provide stats. Any pointers on how to read these stats?

Update: As suggested by Rob Van, I used the tkprof utility to find the performance of my queries. A few parameters I could understand (count,rows,elapsed time,execution time), but most I couldn't. Can anybody help me out with the significance of those parameters? Below are the results.

Query 1:
call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch       49      0.26       0.32         45        494          0       23959
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       51      0.28       0.33         45        494          0       23959

Query2:
call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch       33      0.25       0.24          0        904          0       15992
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       35      0.25       0.24          0        904          0       15992

I can decide that query 2 is better than query 1. Any help on what disk, query and current params mean??

Answer

Jay picture Jay · Aug 21, 2009

There is button above the SQL editor called "Explain Plan". This tool will tell you what each route costs, and how the statement will use indexes and partitions. Note, you may get an error, your DBA will need to turn on a feature for your user account, I believe it is "trace", but could be wrong on that point. Reading the execute statement output can be challenging at first, but it is a good tool to helping write good SQL.