I have a problem with simple query like this (PK - Primary key)
select t1.*, t2.col1, t3.col2
from
T1
inner join T2 on T2.PK = T1.col1
inner join T3 on T3.PK = T2.col1
T1 is very small table ~20-30 rows, T2 and T3 large. In query plan and
monitor output I see table scan on T3. Why?
Index T2_PK has included column col1.
Access Plan:
-----------
Total Cost: 43603.2
Query Degree: 1
Rows
RETURN
( 1)
Cost
I/O
|
3092
HSJOIN
( 2)
43602.9
10783
/------+------\
227641 3092
TBSCAN NLJOIN
( 3) ( 4)
40666.2 2926.35
10361 422.045
| /---+---\
227641 3092 1
TABLE: S TBSCAN IXSCAN
T3 ( 5) ( 8)
406.107 50.016
100 2
| |
3092 64931
SORT INDEX: S
( 6) T2_PK
406.107
100
|
3092
TBSCAN
( 7)
404.727
100
|
3092
TABLE: S
T1
Andy
P.S. UDB 8.2 FP10 win32 7 1948
hey, do you have any index on T3? if not how can they be used?
watch closely! PK - primary key - always have a unique index. I'm try
also create index like (PK) include (col2) because this column used in
select - without success.
Andy
bughunter@ru wrote: watch closely! PK - primary key - always have a unique index. I'm try also create index like (PK) include (col2) because this column used in select - without success.
Andy
This does look odd.
Making T1 the outer and probing T2 and T3 using the PKs is obviously the
better plan.
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
What are column attributes?
Would you show us your DDLs?
DDL is simple like
T1
(DEALID INTEGER NOT NULL, -- PK
APPLID INTEGER NOT NULL, -- T1.Col1
..... -- ~10 short columns like date, dec, int)
T2 (
APPLID INTEGER NOT NULL, -- PK
STOCKID CHARACTER(4) NOT NULL, -- T2.Col1
..... -- ~20 short columns like timestamp, dec, int, char)
T3 (
STOCKID CHARACTER(4) NOT NULL, -- PK
CRDDATE DATE NOT NULL, -- T3.Col1
..... -- ~20 short columns like timestamp, dec, int, char)
bughunter@ru wrote: DDL is simple like
T1 (DEALID INTEGER NOT NULL, -- PK APPLID INTEGER NOT NULL, -- T1.Col1 .... -- ~10 short columns like date, dec, int)
T2 ( APPLID INTEGER NOT NULL, -- PK STOCKID CHARACTER(4) NOT NULL, -- T2.Col1 .... -- ~20 short columns like timestamp, dec, int, char)
T3 ( STOCKID CHARACTER(4) NOT NULL, -- PK CRDDATE DATE NOT NULL, -- T3.Col1 .... -- ~20 short columns like timestamp, dec, int, char)
What's the data you have in there and what's your query?
--
Knut Stolze
DB2 Information Integration Development
IBM Germany
According to your explain output below DB2 seems to believe that there
are 3092 rows in table T1. You seem to think T1 is much smaller. Have
you ran runstats recently? If the size of T1 in the plan explain below
is correct, and if the index on T3_PK is not a clustering one, then it
might actually be cheaper to do the join like shown below (build the
hash table based on the result of T1 join T2, the probe it with rows
from T3).
Regards,
Miro
bughunter@ru wrote: I have a problem with simple query like this (PK - Primary key)
select t1.*, t2.col1, t3.col2 from T1 inner join T2 on T2.PK = T1.col1 inner join T3 on T3.PK = T2.col1
T1 is very small table ~20-30 rows, T2 and T3 large. In query plan and monitor output I see table scan on T3. Why?
Index T2_PK has included column col1.
Access Plan: ----------- Total Cost: 43603.2 Query Degree: 1
Rows RETURN ( 1) Cost I/O | 3092 HSJOIN ( 2) 43602.9 10783 /------+------\ 227641 3092 TBSCAN NLJOIN ( 3) ( 4) 40666.2 2926.35 10361 422.045 | /---+---\ 227641 3092 1 TABLE: S TBSCAN IXSCAN T3 ( 5) ( 8) 406.107 50.016 100 2 | | 3092 64931 SORT INDEX: S ( 6) T2_PK 406.107 100 | 3092 TBSCAN ( 7) 404.727 100 | 3092 TABLE: S T1
Andy
P.S. UDB 8.2 FP10 win32 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Puvendran |
last post by:
Hi,
We have encountered deadlock on a table which is used to generate
sequential numbers for different categories eg typical entries
Category Value
TRADE_NO ...
|
by: JonQuark |
last post by:
Hi,
I'm developing a Javascript intranet app that consists of a number of
windows. I have a variable called TopWin that points to the original,
first window (found using the opener method). Some...
|
by: Otto |
last post by:
Hi,
The application I work on has a table created with a clustered index. A
stored procedure that updates this table is then created while the
table is empty. As i understand it, the access plan...
|
by: Raj |
last post by:
I created a table organized by date dimension. Any queries using the
clustered dimension have huge improvement in query run time. But the
queries doing a table scan table on average 5 - 10 mins...
|
by: Raj |
last post by:
I created a table organized by date dimension. Any queries using the
clustered dimension have huge improvement in query run time. But the
queries doing a table scan table on average take 5 - 10...
|
by: db2admin |
last post by:
hi,
i have query doing tablescan instead index scan. i would explain
situation in more detail.
table has MDC on one column and three more regular indexes. now, one of
the index which has three...
|
by: Raj |
last post by:
Hi all,
I need help tunning the following query
Table scan on table Fact.sale_Current_2005
1.select key,sale_amt,dt,c4,c5,c6,c7 from Fact.sale_Current_view
where dt>= (select (min(Dt))...
|
by: RakshaPai |
last post by:
Hi ,
I am new to mainframes and not able to do much with this issue.. can someone please help me out..
I have a job in which 2 programs take about 5 hours to run taking up 30 mins of CPU time....
|
by: cherukuc |
last post by:
We have a unique issue where a query does a tablescan even though an
index is present. Basically we created a new DB by loading existing
data from a source DB.
The index names and everything else...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |