473,396 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Table scans for larger rowcounts?

DB2 7.2 (7.1.0.68) on AIX 5.2.

I have a query that does a table scan on one database, and an index
scan on another.

The statistics on both databases are up-to-date. Indexes are
identical. Only rowcounts for one of the tables vary (it's using the
index where the table has 1,000 rows, but not where it has 10,000
rows).

Can anyone shed any light on why the optimiser's not picking up the
index consistently?

Here's the offending SQL if helpful:

SELECT MSG.MSG_Q_ID
FROM GFX.VU_INTRL_MSG_Q MSG,
GFX.VU_INTRL_MSG M
WHERE (
( MSG.MEMB_ID = 500000 AND
MSG.REGN_ID IS NULL ) OR
MSG.REGN_ID IN ( SELECT USR.REGN_ID
FROM GFX.VR_USR_ROUTE USR
WHERE USR.REGN_ID = MSG.REGN_ID
AND USR.MEMB_ID = 500000
AND USR.USR_ID =
18006554984185 ) )
AND M.MSG_ID = MSG.MSG_ID
AND ( 'B' IS NULL OR
LOCATE( COALESCE( MSG.MSG_TYPE, M.MSG_TYPE ),
'B' ) > 0 )
AND ( 'DAN' IS NULL OR
LOCATE( M.MSG_CATGY, 'DAN' ) > 0 )
AND ( ( 'A' = 'A' )
OR ( 'A' = 'U'
AND MSG.OWN_USR_ID IS NULL )
OR ( 'A' = 'Y'
AND MSG.OWN_USR_ID IN (SELECT USR_ID
FROM GFX.VU_USR
WHERE
rtrim(UPPR_FULL_NAME) like (rtrim (translate (UCASE ('DAN'), '%',
'*'))) ) )
OR ( 'A' = 'N'
AND MSG.OWN_USR_ID IN (SELECT USR_ID
FROM GFX.VU_USR
WHERE
UPPR_FULL_NAME = ( UCASE('DAN') ) ) )
OR ( 'A' = 'M'
AND MSG.OWN_USR_ID = 18006554984185 )
)
ORDER BY MSG.CRTD_TSTMP DESC
;

Thank you
Bruce
Nov 12 '05 #1
5 1404
AK
are the cluster factors identical?
Nov 12 '05 #2
No, but those indexes with lower cluster ratios are being scanned?!?

INDNAME CLUSTERFACTOR
------------------ ------------------------
XAK1INTRL_MSG_Q +1.00000000000000E+000*
XIE1INTRL_MSG_Q +9.99159663865546E-001*
XIF11168AINTRLMSGQ +1.00000000000000E+000
XIF11168BINTRLMSGQ +7.77310924369748E-001
XIF1196INTRL_MSG_Q +8.84033613445378E-001
XIF1265INTRL_MSG_Q +7.77310924369748E-001
XPKINTRL_MSG_Q +1.00000000000000E+000

INDNAME CLUSTERFACTOR
------------------ ------------------------
XAK1INTRL_MSG_Q +9.80784161490683E-001
XIE1INTRL_MSG_Q +9.99320652173913E-001
XIF11168AINTRLMSGQ +9.80784161490683E-001
XIF11168BINTRLMSGQ +6.24805900621118E-001
XIF1196INTRL_MSG_Q +7.69701086956522E-001
XIF1265INTRL_MSG_Q +6.34025621118012E-001
XPKINTRL_MSG_Q +9.80784161490683E-001

*Those indexes being scanned.
Nov 12 '05 #3
AK
well, the cluster factors are almost identical.
what about the percentage of rows that satisfy the criteria?

For instance, if the query uses an index and returns 50 rows out of 1K
(0.5%), using an index is justified.
If the same query scans the 10K table and returns 8500 rows out of 10K
(85%), that optimizer's choice to scan the table also makes perfect
sense
Nov 12 '05 #4
The query I'm using returns 0 record(s) selected on both databases.
I'm thinking maybe this has something to do with IO / tablespace
container configuration, just not sure how to confirm this. Any tips
much appreciated.
Thanks
Nov 12 '05 #5
AK
you might also want to use OPTIMIZE FOR FIRST and / or SELECTIVITY
clause
that might influence the optimizer to choose the index.
Then you could compare real execution costs and see if choosing the
index what the right thing to do
Nov 12 '05 #6

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

Similar topics

0
by: Carlos Ibarra | last post by:
In various places I have seen mentioned the importance of indexing foreign keys to avoid table locks on the child table on parent update/delete and full table scans when the constraint has action...
5
by: Jim Garrison | last post by:
Scenario: 1) Create a GLOBAL TEMPORARY table and populate it with one (1) row. 2) Join that table to another with about 1 million rows. The join condition selects a few hundred rows. ...
1
by: sumGirl | last post by:
Hi all. Anyone know if sql server collects stats on how many full table scans a table gets and if so how do I get at those stats? Trying to track down poorly indexed tables / processes and I am...
6
by: laurenq uantrell | last post by:
Is it possible to use With (NOLOCK) and With (READPAST) in the same SELECT query and what whould be the syntax? @param int SELECT myRow FROM dbo.myTable WITH (NOLOCK) WHERE
7
by: Bing Wu | last post by:
Hi Folks, I have a very large table containing 170 million rows of coordinats: CREATE TABLE "DB2ADMIN"."COORDINATE" ( "FID" INTEGER NOT NULL , "AID" INTEGER NOT NULL , "X" REAL NOT NULL ,...
6
by: robert | last post by:
just got out of a "class" on EXPLAIN, from a 390/v6 maven. was told that ACCESSTYPE = 'R' in the plan_table meant a TableSpace scan. hmmmm. next step up (or down, depending on your outlook)...
4
by: cmitchell | last post by:
Hi, I am looking for some suggestions as to what i can do to improve the following situation. If there is more detail you require please ask.. There are users inserting/altering data into a...
3
by: deko | last post by:
I'm wondering if there is a better way to see if there are existing records... strRecCount = DCount("Cat_ID", "tblEntity", "=" & !!.Form!.Form!) If this evaluates to 0 then there are no...
2
by: Szymon Dembek | last post by:
Hi I'm trying to tune access times on a table which size might vary (from 0 to at least several thousand records). I've tried marking this table 'volatile' but it caused performance penalties...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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,...

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.