Q
Problem solve Get help with specific problems with your technologies, process and projects.

Explain plan for running a session

I need to get an explain plan for a running session.

* Get value of running SQL
* Get the sql_text from v$sqltext
* But sql_text has linefeed every 64 characters, because of which I can't do an explain plan on this

How can I get an explain plan for this?
If you are running Oracle9i, then this is pretty easy. You can simply query V$SQL_PLAN. All you need is the SQL statement's ADDRESS and HASH_VALUE which can easily be obtained from V$SESSION. If you are not running Oracle9i, then you'll need to extract the SQL text as you've done and then cut and paste that text into a script file. From there, just add the following as the initial line:

EXPLAIN PLAN SET STATEMENT_ID='someid' FOR

The next step is to simply run the script file you just created and then query your PLAN_TABLE to get the explain plan for this statement. Alternatively, if you have access to Top Session in Oracle's Enterprise Manager, then you can drill down to the specific session and look at its SQL statement. Top Session's will show you the explain plan. Other tools from third party vendors will do the same.

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close