baseballtank13
baseballtank13

Reputation: 135

How to view Execution Plans for Oracle Database in Java

With SQL Plus for Oracle Database, I can call

SET autotrace on

and then see Execution Plan, statistics, etc.

The problem is that I want access to information about the Execution Plan and statistics in my Java program. I typically have done something like this to execute a sql statement,

Connection connection = //INITIALIZE HERE;

Statement getColumn = connection.createStatement();

ResultSet results = getColumn.executeQuery("INSERT SQL QUERY HERE");

while(results.next()) { //view results }

Is there a way I can get the Execution Plan and Statistics? Thanks.

Upvotes: 2

Views: 1747

Answers (1)

Chris Taylor
Chris Taylor

Reputation: 53729

You can query the V$SQL_PLAN table to get the explain plain. Alternatively you can query the PLAN_TABLE, you can see more details on this HERE.

Upvotes: 3

Related Questions