Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding Execution time of query using SQL Developer

I am beginner with Oracle DB. I want to know execution time for a query. This query returns around 20,000 records. When I see the SQL Developer, it shows only 50 rows, maximum tweakable to 500. And using F5 upto 5000.

I would have done by making changes in the application, but application redeployment is not possible as it is running on production. So, I am limited to using only SQL Developer. I am not sure how to get the seconds spent for execution of the query ? Any ideas on this will help me. Thank you.

Regards, JE

like image 238
java_enthu Avatar asked Mar 05 '14 13:03

java_enthu


People also ask

How do you find the time taken to execute a SQL query in Oracle?

Answer: For seeing the elapsed time for an individual query, you can see individual query response time in SQL*Plus with the "set timing on" command. For DBA's, Oracle has several tools for measuring system-wide response time using v$sysmetric, v$active_session_history, v$sqlarea and v$sysmetric_summary.

How do I check the performance of a SQL developer query?

In SQL Developer, you can look at the Explain Plan (or Execution Plan) by going into the Worksheet window (where the SQL query is written). Open your query there, or write the query you want to analyse. Now, click Explain Plan, or press F10. The execution plan is shown in SQL Developer.

How do I get the current TIMESTAMP in SQL Developer?

The CURRENT_TIMESTAMP() function returns the current date and time in the session time zone, in a value of datatype TIMESTAMP WITH TIME ZONE. Specifies the fractional second precision of the time value returned. Note: The time zone offset reflects the current local time of the SQL session.

How do I see running queries in SQL Developer?

To monitor long operations: In SQL Developer, click the Reports navigator tab, and expand the hierarchy as follows: All Reports, then Data Dictionary Reports, then Database Administration, then Sessions. Under Sessions, select Active Sessions. If you are asked to select a connection, select one for SYS AS SYSDBA .


1 Answers

You can change those limits; but you'll be using some time in the data transfer between the DB and the client, and possibly for the display; and that in turn would be affected by the number of rows pulled by each fetch. Those things affect your application as well though, so looking at the raw execution time might not tell you the whole story anyway.

To change the worksheet (F5) limit, go to Tools->Preferences->Database->Worksheet, and increase the 'Max rows to print in a script' value (and maybe 'Max lines in Script output'). To change the fetch size go to the Database->Advanced panel in the preferences; maybe to match your application's value.

This isn't perfect but if you don't want to see the actual data, just get the time it takes to run in the DB, you can wrap the query to get a single row:

select count(*) from (
  <your original query
);

It will normally execute the entire original query and then count the results, which won't add anything significant to the time. (It's feasible it might rewrite the query internally I suppose, but I think that's unlikely, and you could use hints to avoid it if needed).

like image 89
Alex Poole Avatar answered Oct 19 '22 03:10

Alex Poole