dave's blog

New Project: trc2sql.pl - Extract SQL from an Oracle Trace...

I started a new project for a utility I started writing. It has some basic functionality now but will probably increase in utility int he future.

It is a Perl script that extracts the SQL statements from an Oracle 10046 trace file. This is useful if you need to re-run SQL that was captured during a trace. It also helps reduce the amount of junk you have to slog through if you are interested in

trc2sql.pl - Extract SQL Statements From Oracle 10046 Trace File


SQL Tuning Advisor - what profile am I accepting?

When working on a SQL Tuning issue I often kick off a SQL Tuning Advisor job on the SQL while I gather info about statistics and other things I like to check when tuning. After I get an idea of where performance might be suffering I use the SQL Tuning Advisor results for a second opion.

Unfortunately more often than not the SQL Tuning Advisor reports it can dramatically improve the performance of a SQL Statement by using a SQL Profile to force a different plan.

A SQL_ID by any other name... Same SQL / Different Tools / Different SQL_ID

I have been trying to chase down the same SQL being submitted against the same Solaris database from different query tools used in our organization. I have been striking out when trying to match up with SQL IDs.

I connected with 5 different tools (including SQLPLUS on 2 platforms) and submitted the following 4 lines of SQL:


Q: How to find the last time a table is queried in Oracle

I want to get the information about when a table is queried in oracle. Is there any log in oracle which shows the queries. I was looking around v$sqlarea and v$sqltext but, the system admin does not allow me to reach those tables. - Dursan @ Stack Overflow

My answer:

Historical Row Counts via Stats History

Ever had a customer asking about the growth of a table? Or suspect an execution plan change might be because of an influx of data into a table?

Well you are in luck (maybe!).

Oracle 10g and 11g have a months worth of historical statistics stored by default. Before stats are gathered for a table their current values are written off into SYS.WRI$OPTSTAT_TAB_HISTORY table.



"The TPC-DS benchmark models the decision support system of a retail product supplier, including queries and data maintenance. Although the underlying business model of TPC-DS is a retail product supplier, the database schema, data population, queries, data maintenance model and implementation rules have been designed to be broadly representative of modern decision support systems."


Moving on up... http://dba.stackexchange.com/

Was cruising StackOverflow today looking for interesting Oracle questions and noticed a DBA specific Stack has been started - it lives at http://dba.stackexchange.com/.

It is database agnostic but I love the Stack setup and the helpful people it attracts. You can filter by Oracle and create an RSS feed on that filter if you aren't interested in going back to the site periodically to find topics you might be interested in.



Using Proxy Connections with SQL Developer or SQLPLUS

When trying to debug for another user sometimes it is helpful to be able to log in as that user. In the past magic was done by admins by storing the encrypted passwords, setting to a new temporary password, logging in, and then resetting the old encrypted password back.

Luckily modern Oracle versions we have the concept of a Proxy user. This allows connecting as one user but masquerading as another user (once proper permissions have been granted of course).

So far I have done this with SQL Developer and SQLPLUS, instructions are below for a test case.

Developer access to 10046 trace files...

Jeremy Schneider posted his code to check the udump directory for trace files and allow remote to access them. Great for developer access or if you are automating access with a tool. Released as GPL as well so you are free to modify the code (after getting familiar with the license that is).



"There was a problem creating a SQL tuning task. ORA-13780: SQL statement does not exist. ORA-06512"

I recently got this error while trying to run a SQL Tuning Task against a SQL statement that was available in AWR but not currently in the library cache.
I got around it by locating the SQL in OEM and using SQL Worksheet to execute it:


Subscribe to RSS - dave's blog