Showing posts with label oracle. Show all posts
Showing posts with label oracle. Show all posts

Monday, April 19, 2010

Oracle Query Analysis

This is the best thing since sliced bread...

set autotrace on exp;
Run Some SQL!

It shows me the bottle necks in my SQL statement, where indexes might help, and give me a pretty accurate estimate on the time the statement will take to run. This is all done within a second for so.

Example output..



Elapsed: 00:00:00.01

Execution Plan
----------------------------------------------------------
Plan hash value: 1080733679

--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 21 | 2 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 21 | | |
| 2 | NESTED LOOPS | | 1 | 21 | 2 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| NG_FILES | 1 | 16 | 2 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN| PK_NG_FILES_ID | 1 | 5 | 0 (0)| 00:00:01 |
--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

3 - filter("DATE_FILE_RECEIVED">=TIMESTAMP' 2009-12-16 00:00:00' AND
"DATE_FILE_RECEIVED"<=TIMESTAMP' 2009-12-17 00:00:00')
4 - access("NG_FILE_ID"="NG_FILE_ID")