EXPLAIN for dynamic SQL.

RDBMS from IBM and IBM's Hierarchical DBMS and Transaction Manager (IMS DC).
Post Reply
Raju Singh
New Member
Posts: 5
Joined: Sun Jun 08, 2014 4:18 pm

EXPLAIN for dynamic SQL.

Post by Raju Singh »

Hi,

Can we EXPLAIN the dynamic SQL in DB2 for zOS. If yes, can you please adivse on how to do that or direct me to a link. We are on DB2 9. I've searched enough but in vain.
User avatar
Anuj Dhawan
Founder
Posts: 2801
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: EXPLAIN for dynamic SQL.

Post by Anuj Dhawan »

The short answer for your version of DB2 is - yes, you can EXPLAIN dynamic DB2 queries. But they are NOT that straight forward.

For static SQL you can force developers to do explains with every pre-compile job. You can analyze and explain the statements in the packages easily. Using ODBC, JDBC, REXX or embedded dynamic SQL, the statements are prepared and executed dynamically and cannot be found in any package. As long as you know your SQL statement, you can explain it using the SQL EXPLAIN command. In some applications, like end user drivers, you even do not know exactly which statements will be executed dynamically. In this case the Resource Limit Facility (RLF) offers you the possibility to govern the resource usage.

Other possibilities to analyze a dynamic SQL statement are to explain it from the statement cache or to trace the access path information of its prepare by means of a DB2 trace. And as we talked about a 'trace', you'd need a monitoring tool to put a trace.

Suggest you've a look at Chapter 18 of this red-bbo: http://www.redbooks.ibm.com/redbooks/pdfs/sg246418.pdf

However, if your shop migrate to DB2 10, which they should - suggest you read about CURRENT EXPLAIN MODE. The CURRENT EXPLAIN MODE special register contains the values that control the EXPLAIN behavior in regards to eligible dynamic SQL statements. This facility generates and inserts EXPLAIN information into the EXPLAIN tables.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Venkata Kumar
New Member
Posts: 5
Joined: Wed Jul 30, 2014 12:12 pm

Re: EXPLAIN for dynamic SQL.

Post by Venkata Kumar »

We've used Mainview to put a trace and it has helped.
User avatar
Anuj Dhawan
Founder
Posts: 2801
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: EXPLAIN for dynamic SQL.

Post by Anuj Dhawan »

Yes - BMC MainView helps you to monitor system health and you can put traces on transactions etc. to analyze them.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Raju Singh
New Member
Posts: 5
Joined: Sun Jun 08, 2014 4:18 pm

Re: EXPLAIN for dynamic SQL.

Post by Raju Singh »

Thanks for the detailed explanation Anuj.
User avatar
Anuj Dhawan
Founder
Posts: 2801
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: EXPLAIN for dynamic SQL.

Post by Anuj Dhawan »

Thanks for the feedback and glad to see that it helped.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Raju Singh
New Member
Posts: 5
Joined: Sun Jun 08, 2014 4:18 pm

Re: EXPLAIN for dynamic SQL.

Post by Raju Singh »

yup, anytime! :)
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DB2 and IMS DB/DC”