dbTalk Databases Forums  

EXPLAIN SQL against DGTTs

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss EXPLAIN SQL against DGTTs in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
jefftyzzer
 
Posts: n/a

Default EXPLAIN SQL against DGTTs - 10-03-2007 , 12:27 PM






Friends:

Anyone know how I can EXPLAIN a dynamic SQL statement that SELECTs
from DGTT's in a stored procedure?

I don't want to create permanent versions of the DGTTs and run an
explain against them, as I want to see what the optimizer's *really
doing*.
Thanks,

--Jeff


Reply With Quote
  #2  
Old   
Serge Rielau
 
Posts: n/a

Default Re: EXPLAIN SQL against DGTTs - 10-03-2007 , 01:01 PM






jefftyzzer wrote:
Quote:
Friends:

Anyone know how I can EXPLAIN a dynamic SQL statement that SELECTs
from DGTT's in a stored procedure?

I don't want to create permanent versions of the DGTTs and run an
explain against them, as I want to see what the optimizer's *really
doing*.
I think you need to use EXPLAIN ALL and actually execute the procedure.

Cheers
Serge


--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


Reply With Quote
  #3  
Old   
jefftyzzer
 
Posts: n/a

Default Re: EXPLAIN SQL against DGTTs - 10-03-2007 , 01:21 PM



On Oct 3, 11:01 am, Serge Rielau <srie... (AT) ca (DOT) ibm.com> wrote:
Quote:
jefftyzzer wrote:
Friends:

Anyone know how I can EXPLAIN a dynamic SQL statement that SELECTs
from DGTT's in a stored procedure?

I don't want to create permanent versions of the DGTTs and run an
explain against them, as I want to see what the optimizer's *really
doing*.

I think you need to use EXPLAIN ALL and actually execute the procedure.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Thanks, Serge. I had tried that earlier, (complete with stopping and
restarting) but it didn't seem to do the trick, as the only SQL I saw
in EXPLAIN_INSTANCE after running db2exfmt (after kicking-off the SP)
was earlier-run (and static) SQL. However, as the SQL was only dynamic
because of the use of DGTT's, I was able to get what I needed by
declaring the DGTT and explaining the query against it in CLP.

On the issue of DGTTs requiring that any SQL run against them be
dynamic, what's the story on that? Unless I misunderstand, the SQL/PL
book by Janmohammed, et al. says that, on LUW, SQL that SELECTs from
DGTTs must be dynamic due to "object dependencies [being] resolved at
procedure build time," while I've also read that all that's actually
needed is that the SQL be located within a separate BEGIN...END block
from the one the DGTT is declared in. What say you?

As always, thanks.

--Jeff Tyzzer



Reply With Quote
  #4  
Old   
Serge Rielau
 
Posts: n/a

Default Re: EXPLAIN SQL against DGTTs - 10-03-2007 , 04:52 PM



jefftyzzer wrote:
Quote:
On Oct 3, 11:01 am, Serge Rielau <srie... (AT) ca (DOT) ibm.com> wrote:
jefftyzzer wrote:
Friends:
Anyone know how I can EXPLAIN a dynamic SQL statement that SELECTs
from DGTT's in a stored procedure?
I don't want to create permanent versions of the DGTTs and run an
explain against them, as I want to see what the optimizer's *really
doing*.
I think you need to use EXPLAIN ALL and actually execute the procedure.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

Thanks, Serge. I had tried that earlier, (complete with stopping and
restarting) but it didn't seem to do the trick, as the only SQL I saw
in EXPLAIN_INSTANCE after running db2exfmt (after kicking-off the SP)
was earlier-run (and static) SQL. However, as the SQL was only dynamic
because of the use of DGTT's, I was able to get what I needed by
declaring the DGTT and explaining the query against it in CLP.
Did you set the routine options? And drop/create the proecdure?

Quote:
On the issue of DGTTs requiring that any SQL run against them be
dynamic, what's the story on that? Unless I misunderstand, the SQL/PL
book by Janmohammed, et al. says that, on LUW, SQL that SELECTs from
DGTTs must be dynamic due to "object dependencies [being] resolved at
procedure build time," while I've also read that all that's actually
needed is that the SQL be located within a separate BEGIN...END block
from the one the DGTT is declared in. What say you?
Any static SQL which refers to the SESSION schema immediately gets
placed into "validate run". That is the statement will be compiled when
it gets executed for the first time.

That is DB2 is happy if the statement is syntactically correct.
Now in SQL Procedures that is not good enough because DB2 needs to
figure out what's a column and what's a variable. Thus when creating the
procedure the DGTT must either exist or it must be declared within the
stored procedure itself.
What I recommend is that DGTT are collectively defined in an "init"
procedure.
This way, before you create a procedure using such beasts you simply
CALL INIT() and everything is set up properly the way it will be when
the procedure actually runs.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


Reply With Quote
  #5  
Old   
4.spam@mail.ru
 
Posts: n/a

Default Re: EXPLAIN SQL against DGTTs - 10-04-2007 , 07:36 AM



Quote:
Did you set the routine options? And drop/create the proecdure?

Cheers
Serge
I always wanted to know: are there plans in future not to drop/create
the procedure to switch explain behaviour for "static" sql with DGGT?
It's very inconvenient.
I would like to do it with rebind statement, for example...

Sincerely,
Mark Barinstein.



Reply With Quote
  #6  
Old   
Serge Rielau
 
Posts: n/a

Default Re: EXPLAIN SQL against DGTTs - 10-05-2007 , 06:57 AM



4.spam (AT) mail (DOT) ru wrote:
Quote:
Did you set the routine options? And drop/create the proecdure?

Cheers
Serge

I always wanted to know: are there plans in future not to drop/create
the procedure to switch explain behaviour for "static" sql with DGGT?
It's very inconvenient.
I would like to do it with rebind statement, for example...
Reasonable request... no plans that I'm aware of.
There are plans to make drop/create less invasive though.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.