Unix Technical Forum

a strange sql explain

This is a discussion on a strange sql explain within the DB2 forums, part of the Database Server Software category; --> two tables with the same table structure : tb_xxx and tb_xxx_tmp in table tb_xxx , column "listno" is the ...


Go Back   Unix Technical Forum > Database Server Software > DB2

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 08:12 AM
heming_g@hotmail.com
 
Posts: n/a
Default a strange sql explain

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 .

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 08:12 AM
Phil Sherman
 
Posts: n/a
Default Re: a strange sql explain

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



heming_g@hotmail.com wrote:
> 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 .
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 08:17 AM
heming_g@hotmail.com
 
Posts: n/a
Default Re: a strange sql explain


Phil Sherman wrote:
> 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
>
>
>
> heming_g@hotmail.com wrote:
> > 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 .
> >


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 .

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:59 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com