![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
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 |
#4
| |||
| |||
|
|
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? |
|
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 |
#5
| |||
| |||
|
|
Did you set the routine options? And drop/create the proecdure? Cheers Serge |
#6
| |||
| |||
|
|
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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |