473,594 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sort after index scan

Raj
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

Mar 13 '06 #1
7 1612
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

Mar 13 '06 #2
Raj
Thanks for the reply
The index is created with allowscan option and our sort heap is 8000
pages on 6 logical nodes ..

Mar 13 '06 #3
have you do runstats on the very table?

Mar 14 '06 #4
Raj
Yeah stats are current on the table ..
Hardy wrote:
have you do runstats on the very table?


Mar 14 '06 #5
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

Mar 14 '06 #6
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

Mar 14 '06 #7
Raj wrote:
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


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

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Mar 15 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3201
by: One's Too Many | last post by:
Ran into a strange problem today: 8.1.7 on AIX 4.3.3 Database and applications had been working fine for two years and all of a sudden a couple of regularly-run queries are now no longer coming out in correct sort order specified in the ORDER clauses of the select statements. Behavior is erratic, about half the time the sort order is correct, and the other half is not. All expected rows are being returned (no data is missing) and the...
3
5683
by: Carlos Moreno | last post by:
I can't find a reasonable explanation for this. I have a table game, with primary key gameid (an int). If I use a where involving gameid and <, or >, or <=, or >=, then I get a sequential scan. If I use =, then of course I get an Index scan. More surprising to me is the fact that using BETWEEN, I get an Index scan!!
5
503
by: Gerard M. Operana | last post by:
unsubscribe
4
4472
by: P Adhia | last post by:
Hello, If the explain shows that DB2 needs to sort the result of a cursor, does that always happen? i.e. if the resultset of the cursor is empty, does the sort have any overhead? It appears that, majority of the time is spent in allocation and deallocation of the temporary file to hold the data for the sort. Do these activities still take place for an empty cursor? Also, DB2 manual appears to say that only RID sorts are done in
1
6730
by: Gorilla | last post by:
I bound my package with EXPLAIN(YES), and it's got the following static SQL in it: EXEC SQL SELECT CARDF, RECLENGTH INTO :CARDF,:RECLENGTH FROM SYSIBM.SYSTABLES WHERE NAME = :TBNAME AND CREATOR = :TBCREATOR The explain shows that it does a *full table scan* on SYSIBM.SYSTABLES!
8
9232
by: Mike Wertheim | last post by:
Hi, I'm using PostgreSQL 8. I have two tables that I am doing a join on, and the join executes very slowly. The table called Notification has a text field called NotificationID, which is its primary key. The Notification table also has an int4 field called ItemID, and it has an index on the ItemID field. The table
2
2490
by: BD | last post by:
Hi, all. My background is more Oracle than db2. My skills at SQL tuning are quite limited. I'm running 8.2 on Windows. I'm tasked with some SQL optimization, and am doing some explain plans on various queries.
1
1482
mfshake
by: mfshake | last post by:
i am using only a driver and not a server. I know how to do selection sort for ints but can't figure out how to do it for Strings. I want to sort it my first letter only Here is my code that i started: private static void selectionSort(String a) { String array = a; int min, temp; for (int index = 0; index < a.length - 1; index++) { min = index;
1
3203
by: Steffen Stellwag | last post by:
Truely is often better to scan a table in full passing by an index , but if you can force the optimizer to use an index via a hint for testing and comparing the results. But the index in the above example is not used , because the hint is malformed, if tables in a Select statment are named by aliases you have to specify the alias name in the hint statment , not the table name /*+ INDEX (ICWOIMP PK_ICWOIMP) */ change to /*+ INDEX (A...
0
7874
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8246
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8368
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5738
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5404
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3895
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1476
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.