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_MS G_Q MSG,
GFX.VU_INTRL_MS G 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_ROUT E 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 5 1427
are the cluster factors identical?
No, but those indexes with lower cluster ratios are being scanned?!?
INDNAME CLUSTERFACTOR
------------------ ------------------------
XAK1INTRL_MSG_Q +1.000000000000 00E+000*
XIE1INTRL_MSG_Q +9.991596638655 46E-001*
XIF11168AINTRLM SGQ +1.000000000000 00E+000
XIF11168BINTRLM SGQ +7.773109243697 48E-001
XIF1196INTRL_MS G_Q +8.840336134453 78E-001
XIF1265INTRL_MS G_Q +7.773109243697 48E-001
XPKINTRL_MSG_Q +1.000000000000 00E+000
INDNAME CLUSTERFACTOR
------------------ ------------------------
XAK1INTRL_MSG_Q +9.807841614906 83E-001
XIE1INTRL_MSG_Q +9.993206521739 13E-001
XIF11168AINTRLM SGQ +9.807841614906 83E-001
XIF11168BINTRLM SGQ +6.248059006211 18E-001
XIF1196INTRL_MS G_Q +7.697010869565 22E-001
XIF1265INTRL_MS G_Q +6.340256211180 12E-001
XPKINTRL_MSG_Q +9.807841614906 83E-001
*Those indexes being scanned.
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 ON
DELETE CASCADE. For example, see
http://asktom.oracle.com/pls/ask/f?p=4950:8:10827638093976934265::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:292016138754,
However, if I have no index on the FKs, the only mention of full table
scans on the...
|
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.
Performance: 4 seconds, the system is doing a full-table
scan of the second table, and the Explain Plan output
|
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 guessing that
sql server does have this data secreted away somewhere much like my
db2 and informix databases do.
|
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
|
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 ,
"Y" REAL NOT NULL ,
"Z" REAL NOT NULL )
| |
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) wasn't a
Table Scan.
thought this might be a MainFrame thing; but a look at DB2Info on my
UDB 7.2 server showed the same thing.
this is truly puzzling. is there an explanation of EXPLAIN which
describes how to get a Table Scan???? or are we...
|
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 table at a good pace.
Since they have been entering in data i have to perform a reorg daily.
Yesterday the reorgchk utility tells me the F2 and F3 table statistics
are out of their thresholds and places an asterisk under columns F2 and
F3. Also...
|
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 records in this category.
Is there a better way? If so, Why is it better?
|
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 on some operations:
- table scan from 10 to 200 timerons
- index scan from 15 to 500 timerons
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |