Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / June 2006

Tip: Looking for answers? Try searching our database.

tablescan instead index scan

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
db2admin - 02 Jun 2006 21:00 GMT
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 columns has bad index ratio ( 40 ) due to
dimension on other column. cluster ratio does not go up even if i do
runstats or reorgs. is there any way i can force to do index scan
m0002a@yahoo.com - 02 Jun 2006 21:06 GMT
> hi,
>
[quoted text clipped - 4 lines]
> dimension on other column. cluster ratio does not go up even if i do
> runstats or reorgs. is there any way i can force to do index scan

It would help if you could post the DDL for the table and indexes (and
MDC), and the DML for the SQL query.
db2admin - 02 Jun 2006 21:49 GMT
> > hi,
> >
[quoted text clipped - 7 lines]
> It would help if you could post the DDL for the table and indexes (and
> MDC), and the DML for the SQL query.

ok

due to buisness reasons, i can not post ddl and sql but i can try to
give example close to real situation

table A     |   table B     |   table C
aa int,      |    ba int,         |    ca int,
ab int,      |    bb int,         |    cb int,
ac int,      |     bc date        |  cc int,
ad date,   |              |  cd date
ae date,   |              |
af date,    |               |
ag date    |              |

there is mdc on each table on column ad date, bc date, cd date
there is regular index like

index a on table a
aa asc, ab asc, ac asc

index b on table b
ba asc, bb asc

index c on table c
ca asc, cb asc, cc asc

and sql is like

select (some coulmns from table a,b,c) from a,b,c
where a.aa = b.ba and a.ab = b.bb and a.aa = c.ca and a.ab = c.cb
and ag between (current date - 42 months) and (current date)
and bc between (current date - 42 months) and (current date)

now it is using dimansional block index because its cluster ratio is
100% but skipping index a or b or c which has column used in join

those indexes has bad cluster ratio which can not avoided

how should i go about this
i think sql will improve if it use regular indexes along with block
indexes
db2admin - 02 Jun 2006 21:53 GMT
> > > hi,
> > >
[quoted text clipped - 49 lines]
> i think sql will improve if it use regular indexes along with block
> indexes

it does tablescan even if i do not use dimension column in my sql
ChrisC - 05 Jun 2006 16:30 GMT
> i think sql will improve if it use regular indexes along with block
> indexes

Actually, I wouldn't be suprised if skipping the indexes and doing full
table scans isn't the best choice.  Looking at the query, the only
limiting columns are against ag (which isn't indexed), and bc (which is
the MDC column).  However, bc is for 3 1/2 years of data - just how
much data do you have in this table?  If it's only4 years or so, this
isn't selective enough for DB2 to bother with - it would likely return
most of the data in any case.  If you have 20-30 years of data in
there, then it might make sense to use the MDC to filter this -
assuming that the 3-1/2 years of data is a small enough percentage of
the data (maybe < 50%, max).  Then it should use the other indexes for
joining, most likely.

Otherwise, DB2 probably thinks it will need to pull in all the data
from all the tables to do the joins - and in that case, doing table
scans is definitely more effecient than running the indexes (since
those indexes are not clustered).

-Chris
db2admin - 05 Jun 2006 19:31 GMT
> > i think sql will improve if it use regular indexes along with block
> > indexes
[quoted text clipped - 17 lines]
>
> -Chris

i am sorry
i was not ag
it was ad ( mdc index )
Shashi Mannepalli - 02 Jun 2006 21:35 GMT
This could be related ...But as others mentioned it would great if u
post all the
Information in detail

Queries on an MDC table cannot use an index-only access since DB2®
Universal Database™ (DB2 UDB) needs to do a FETCH as well to check
the first page of each block returned by the index scan to see if it
has any records in it. This is due to empty blocks sometimes left on a
table which can't be freed. These are called phantom blocks.

If there is a start/stop key on the index to delimit the search, this
can reduce the number of active blocks that need to be searched but if
not, then all active blocks need to be searched. To find out how many
active blocks there are, query the ACTIVE_BLOCKS column against the
system catalog tables.

cheers...
Shashi Mannepalli

> hi,
>
[quoted text clipped - 4 lines]
> dimension on other column. cluster ratio does not go up even if i do
> runstats or reorgs. is there any way i can force to do index scan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.