Subject | Re: [Firebird-Java] Get execution plan through JDBC |
---|---|
Author | Mark Rotteveel |
Post date | 2014-03-03T11:37:29Z |
On 02 Mar 2014 14:01:18 -0800, <IJFQSFTGESJU@...> wrote:
Statement stmt = ...;
FirebirdStatement fbstmt = stmt.unwrap(FirebirdStatement .class); // or:
FirebirdStatement fbstmt = (FirebirdStatement ) stmt;
fbstmt.getLastExecutionPlan();
This works for all statement types, with a 'normal' statement this only
works after you executed the statement. With a PreparedStatement or
CallableStatement it always works. For a PreparedStatement or
CallableStatement you can also cast (or unwrap) to
FirebirdPreparedStatement (or FirebirdCallableStatement) and call
getExecutionPlan().
A ResultSet when cast or unwrapped to FirebirdResultSet also has a
getExecutionPlan() method.
In all cases the return type is a string with the Firebird plan.
Mark
> Hello,&
> how can I get the execution plan of a query through JDBC (using Jaybird
> Firebird)?back
>
> In Postgres or Oracle I can simply run "explain" and get a ResultSet
> when using executeQuery().Firebird,
> As far as I can tell there is no "explain" or "explain plan" in
> so how can I retrieve the execution plan for an arbitrary SQL statementYou can use
> (available as a String)?
Statement stmt = ...;
FirebirdStatement fbstmt = stmt.unwrap(FirebirdStatement .class); // or:
FirebirdStatement fbstmt = (FirebirdStatement ) stmt;
fbstmt.getLastExecutionPlan();
This works for all statement types, with a 'normal' statement this only
works after you executed the statement. With a PreparedStatement or
CallableStatement it always works. For a PreparedStatement or
CallableStatement you can also cast (or unwrap) to
FirebirdPreparedStatement (or FirebirdCallableStatement) and call
getExecutionPlan().
A ResultSet when cast or unwrapped to FirebirdResultSet also has a
getExecutionPlan() method.
In all cases the return type is a string with the Firebird plan.
Mark