a strange sql explain

DATABASE

    Next

  • 1. cpytoimpf failing on V5R4
    Hi, I am running an application on V5R4 which utilises CPYTOIMPF command. The application is crashing at CPYTOIMPF when tried to run more than three times. If I sign off and sign on again, then the application is working for another three aor four times and then crashing. The same application is working in V5R2 without any trouble. Is there any change in CPYTOIMPF in V5R4? if so is there any PTF to rectify this error?
  • 2. How can REORGCHK and REORG be used together in a Script to select DB2 UDB objects to Reorg?
    Hi all, How can I implement using REORGCHK to tell REORG what DB2 UDB v8 tables, etc to perform REORG on? Any example script will be highly appreciated. Okonita
  • 3. Taking over from another DBA: What should I want to know?
    Hi all, I am due to take over DBA functions for a DB2 UDB LUW. I am meeting with the outgoing DBA soon and I thought I should ask this vast base of kowledgeable practitioners what are the questions they would want to ask the outgoing DBA if they were in my shoes. There is not much documentation on shop practices and procedures, type of or critical applications running (every thing is in everyones head), what and who (he! he!) to watch out for, etc. Please share with me your thoughts and examples how you might go about getting as much information from and covering major areas of managing a UDB environment... Thanks Okonita
  • 4. Vexing Problem with DB2 UDB Design Advisor? Any Suggestion, please!
    Hello community, My environment is DB2 UDB v8.2 LUW. I am experiencing a vexing problem with using my DB2 Design Advisor. I submitted a SQL script to Advisor for index recommendation and I am getting the error: IBM][CLI Driver][DB2/LINUX] SQL0180N The syntax of the string representation of a datetime value is incorrect. SQLSTATE"007 Explanation: The string representation of a date, time, or timestamp value does not conform to the syntax for the specified or implied data type. The statement cannot be processed. And here's the part of my SQL that I suspect is causing this error "...and Updt.DT_When_CMPL BETWEEN (timestamp((current_date- (day(current_date)-1)days -1 month),'00:00:00')) AND (timestamp(Date(current_date-day(current_date)days ),'23:59:59'))"... I have no errors running the complete SQL in Control Center Command Editor, or Task Center but the Design Advisor seems to take an issue with that construct. Anyone run into this proble? Can anyone suggest a solution and if possible share the step by step example/procedure how to resolve this? I thank you for your attention and help Okonita
  • 5. Restoring, can't redirect tablespaces
    DB2 9.1.3 on Windows. If I take a backup from a system where all DB2 data is on drive D: and try to restore or "create from backup", onto drive E: of another system, I find: - System managed tablespaces can be redirected ok - Database managed tablespaces cannot be redirected, but insist on using drive D:. If drive D: doesn't exist, or is a CD, the restore fails. Is this to be expected? --Greg Nash

a strange sql explain

Postby heming_g » Thu, 01 Jun 2006 18:46:56 GMT

two tables with the same table structure : tb_xxx and tb_xxx_tmp

in table tb_xxx , column "listno" is the primary key of itself and
foreign key of  dozen of  tables .

here is my sql .. " update tb_xxx set ( listno ) = (select listno from
tb_xxx_tmp where listno = 11 ) where listno = 11 "

the explain result (use db2expln ) is amazing ... about a thousand
lines !!!! ,refering all of the dozen of  tables . but when i try
anther two table tb_yyy and tb_yyy_tmp .

its explain is simple :

                                                     UPDATE
                                                       |    |
                                              NLJOIN   TB_yyy
                                               |       |
                                      TB_yyy    TB_yyy_tmp

the difference between tb_xxx and tb_yyy is that tb_yyy is less refered
by other tables .


Re: a strange sql explain

Postby Phil Sherman » Fri, 02 Jun 2006 04:52:54 GMT

Check the SQL Reference, Vol 2; CREATE TABLE; FOREIGN KEY; ENFORCED.

Any time a parent row is deleted, the dependent table should be examined 
to determine what to do with rows that matched the modified parent. The 
ENFORCED parameter is used to control database manager checking of the 
constraint.

I'd check the definitions for dependents of xxx and yyy to see if they 
use different enforcement options. This would easily account for the 
explain differences.

Phil Sherman






Re: a strange sql explain

Postby heming_g » Thu, 08 Jun 2006 17:46:20 GMT





actually , their definition are the same without  ENFORCED parameter .
the question is when the update statement is simple as " update xxx set
a = 1 " , its explain result is normal . but when it comes to "update
xxx set  (a) = (select a from ...) " . the explain result is refering
all of its depandent tables .


Similar Threads:

1.Explain SQL strange syntax, please

In revising some of my old MySQL scripts, existing syntax works, but
I've no reason why (or where I got it from  to begin with).

Ex. Using MySQL in PHP to INSERT a row, the VALUES segment lists some
values like this:

$setsqlcall = "INSERT INTO a_table (
  a_name,
  a_time )
  VALUES (
    '".$aname."',
    '".$atime."')";

Most examples show simply '$aname' and '$atime'.  Why the '".$var."'
syntax - extra pairings of 'double-quote & period ... period &
double-quote' inside paired single-quotes.

In searching for answers I have seen '"+$var+"' too.

Could sometime explain this for me.  (Also, if you know where
explanation are to be found for this, I'd like to know that too.)

Thanks,   RG

2.experimenting with coalesce, strange EXPLAIN results

I was experimenting with moving some of my case logic out of the 
application and into sql and found  a strange EXPLAIN result with one of 
my COALESCE statements.  Why is each subselect listed twice?  This is in 
7.3.4 on freebsd 4.8.

cms3=# explain analyze select coalesce ((sELECT thumb FROM content_group_descriptor WHERE content_group_id = 140 AND language_id = 1),(SELECT tc.file FROM thumbnail_content tc, ccl WHERE tc.parent_content_id = cid AND ccgid = 140 limit 1));
                                                                       QUERY PLAN                                                                       
--------------------------------------------------------------------------------------------------------------------------------------------------------
 Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.98..0.98 rows=1 loops=1)
   InitPlan
     ->  Seq Scan on content_group_descriptor  (cost=0.00..2.78 rows=1 width=4) (actual time=0.10..0.10 rows=0 loops=1)
           Filter: ((content_group_id = 140) AND (language_id = 1))
     ->  Seq Scan on content_group_descriptor  (cost=0.00..2.78 rows=1 width=4) (never executed)
           Filter: ((content_group_id = 140) AND (language_id = 1))
     ->  Limit  (cost=0.00..8.43 rows=1 width=12) (actual time=0.35..0.42 rows=1 loops=1)
           ->  Nested Loop  (cost=0.00..14.94 rows=2 width=12) (actual time=0.34..0.40 rows=2 loops=1)
                 ->  Seq Scan on content_collection  (cost=0.00..5.46 rows=1 width=4) (actual time=0.24..0.26 rows=3 loops=1)
                       Filter: (content_collection_group_id = 140)
                 ->  Index Scan using parent_file_key on thumbnail_content tc  (cost=0.00..6.83 rows=1 width=8) (actual time=0.02..0.02 rows=1 loops=3)
                       Index Cond: (tc.parent_content_id = "outer".content_id)
     ->  Limit  (cost=0.00..8.43 rows=1 width=12) (actual time=0.32..0.39 rows=1 loops=1)
           ->  Nested Loop  (cost=0.00..14.94 rows=2 width=12) (actual time=0.31..0.37 rows=2 loops=1)
                 ->  Seq Scan on content_collection  (cost=0.00..5.46 rows=1 width=4) (actual time=0.24..0.26 rows=3 loops=1)
                       Filter: (content_collection_group_id = 140)
                 ->  Index Scan using parent_file_key on thumbnail_content tc  (cost=0.00..6.83 rows=1 width=8) (actual time=0.01..0.02 rows=1 loops=3)
                       Index Cond: (tc.parent_content_id = "outer".content_id)
 Total runtime: 1.14 msec
(19 rows)




---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to  XXXX@XXXXX.COM 

3.Looking for help building 'rhdb-explain' Visual Explain tool

I'm hoping there's someone here with experience in building the Visual
Explain tool from Red Hat. I downloaded it and the J2 SDK, but when I
attempt to follow the build instructions, I get messages like:

error: Type `JTableHeader' not found in the declaration of the local
variable `header'.
    [javac]             JTableHeader header = null;

To me, this indicates that the SDK isn't installed (properly). But I
admit I'm pretty much a Java know-nothin'.

4.Looking for help building 'rhdb-explain' Visual Explain

Jeff Boes wrote:
> I'm hoping there's someone here with experience in building the Visual
> Explain tool from Red Hat. I downloaded it and the J2 SDK, but when I
> attempt to follow the build instructions, I get messages like:
> 
> error: Type `JTableHeader' not found in the declaration of the local
> variable `header'.
>     [javac]             JTableHeader header = null;
> 
> To me, this indicates that the SDK isn't installed (properly). But I
> admit I'm pretty much a Java know-nothin'.
> 

Jeff, have tou set the environment variable JAVA_HOME to where your SDK 
is installed?

Please try:

echo $JAVA_HOME

and

which javac


Regards,
Fernando

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to  XXXX@XXXXX.COM  so that your
      message can get through to the mailing list cleanly

5.Explain plan for SQL stored procedure

Hi,

I want to get a full EXPLAIN plan of my SQL stored procedure. I found out
that you can set environmental variables by using db2set. So I added the
line:

DB2_SQLROUTINE_PREPOPTS=EXPLAIN ALL

But when I use db2expln like:

db2expln -d <db> -u <username> <password> -o c:\explain.txt -c <creator> -p
<package_id> -s 0

I see all different sections but without a plan (same as before I changed
the db2set option). For most sections a line is written stating "Section
will be recompiled at next use.".

What I then did was executing a CALL statement on this SQL stored procedure
with not effect. I also tried to REBIND the package.

I also performed a db2stop and db2start so that maybe the
DB2_SQLROUTINE_PREPOPTS was initialized, also this had no effect.

I wonder whether the sections in my SQL stored procedures get precompiled
everytime or that I have to perform some more actions to get a well-formed
explain plan.


Thanks for any help,

Onno Ceelen


6. SQL explain plan

7. EXPLAIN SQL against DGTTs

8. Getting SQL0901N error with SQL State: 58004 on running explain plans



Return to DATABASE

 

Who is online

Users browsing this forum: No registered users and 91 guest