Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old March 13th, 2006, 04:55 PM
Raj
Guest
 
Posts: n/a
Default Sort after index scan

Hi,

I have a pretty simple query like

select
t1.c1,t1.c2,t1.c2,
t2.c1,t2.c2
from t1, t2

where t1.c1 = ' xxx '
and t2.c2 >'xxx'

t1 and t2 have nonunique index on c1 and c2
t1 card 978,815,058
t2 card 52308


what i don't undertand is, for t1 there is a sort after index scan
which is spilling to the disk as causing the query to run very slowly,
why is it doing a sort after the IXSCAN???

5.58051e+07
RIDSCN
( 6)
2.61989e+06
472267
|
5.58051e+07
SORT
( 7)
2.15091e+06
249935
|
5.58051e+07
IXSCAN
( 8)
91817.1
27602.9

Thanks a lot,
Raj




  #2  
Old March 13th, 2006, 06:15 PM
Shashi Mannepalli
Guest
 
Posts: n/a
Default Re: Sort after index scan

My few cents

1. Did u try creating those indexes using ALLOW REVERSE SCANS option ?
Just run db2advis on the given SQL it will give u the correct syntax of
the INDEXES.

2. Did u try increasing the SORTHEAP ?

cheers...
Shashi Mannepalli

  #3  
Old March 13th, 2006, 07:25 PM
Raj
Guest
 
Posts: n/a
Default Re: Sort after index scan

Thanks for the reply
The index is created with allowscan option and our sort heap is 8000
pages on 6 logical nodes ..

  #4  
Old March 14th, 2006, 02:35 AM
Hardy
Guest
 
Posts: n/a
Default Re: Sort after index scan

have you do runstats on the very table?

  #5  
Old March 14th, 2006, 02:15 PM
Raj
Guest
 
Posts: n/a
Default Re: Sort after index scan

Yeah stats are current on the table ..
Hardy wrote:[color=blue]
> have you do runstats on the very table?[/color]

  #6  
Old March 14th, 2006, 02:25 PM
sethwai@yahoo.com
Guest
 
Posts: n/a
Default Re: Sort after index scan

It looks like it is sorting the rids to make for more effecient table
access. This way it will only access the pages with the required rows.
The optimizer has determined that this will be faster than reading an
index record and then getting its' associated row one at a time. It
kind of makes sense as the > comparison may bring back a large number
of rows. It might choose not to do the sort if the index on t1
clusters the table. Does it cluster the table?

Lew

  #7  
Old March 14th, 2006, 02:35 PM
sethwai@yahoo.com
Guest
 
Posts: n/a
Default Re: Sort after index scan

Oops. I goofed on that one. I got the t1 and t2 clauses mixed up.
Sorry about that. Hmmm. Is there the chance of a large number (I'm
talking very large) of duplicate 'xxx' entries for the t1 table?

Lew

  #8  
Old March 15th, 2006, 07:35 AM
Knut Stolze
Guest
 
Posts: n/a
Default Re: Sort after index scan

Raj wrote:
[color=blue]
> Hi,
>
> I have a pretty simple query like
>
> select
> t1.c1,t1.c2,t1.c2,
> t2.c1,t2.c2
> from t1, t2
>
> where t1.c1 = ' xxx '
> and t2.c2 >'xxx'
>
> t1 and t2 have nonunique index on c1 and c2
> t1 card 978,815,058
> t2 card 52308
>
>
> what i don't undertand is, for t1 there is a sort after index scan
> which is spilling to the disk as causing the query to run very slowly,
> why is it doing a sort after the IXSCAN???
>
> 5.58051e+07
> RIDSCN
> ( 6)
> 2.61989e+06
> 472267
> |
> 5.58051e+07
> SORT
> ( 7)
> 2.15091e+06
> 249935
> |
> 5.58051e+07
> IXSCAN
> ( 8)
> 91817.1
> 27602.9[/color]

What's the complete plan? Maybe DB2 is picking a sort/merge join or so?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,414 network members.