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")

Thursday, April 1, 2010

Linux Commands

A few commands I find myself using from time to time and don't want to forget.

To examine a large log with logj4, STDIN, STDOUT, and STDERR printouts all going to the same log file, I find it easier to comb when I can narrow down to specific type(s) of log4j level statements and show them without line breaks.

grep "^\[TRACE\|DEBUG\|INFO\|ERROR\|WARN\|FATAL\]" my.log | less -S

Also, to recursively add files in your svn working copy...

svn status | grep "^\?" | awk '{print $2}' | xargs svn add