EXPLAIN for dynamic SQL.
-
- New Member
- Posts: 5
- Joined: Sun Jun 08, 2014 4:18 pm
EXPLAIN for dynamic SQL.
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.
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.
- Anuj Dhawan
- Founder
- Posts: 2824
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: EXPLAIN for dynamic SQL.
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.
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.
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.
-
- New Member
- Posts: 5
- Joined: Wed Jul 30, 2014 12:12 pm
- Anuj Dhawan
- Founder
- Posts: 2824
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: EXPLAIN for dynamic SQL.
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.
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.
-
- New Member
- Posts: 5
- Joined: Sun Jun 08, 2014 4:18 pm
- Anuj Dhawan
- Founder
- Posts: 2824
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: EXPLAIN for dynamic SQL.
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.
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.
-
- New Member
- Posts: 5
- Joined: Sun Jun 08, 2014 4:18 pm
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