Unix Technical Forum

Optimiser choice of index

This is a discussion on Optimiser choice of index within the Informix forums, part of the Database Server Software category; --> IDS 7.31.FD7 Solaris 9 We have a query that rans in <1 sec using a 2 column composite index ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 10:15 AM
Colin Dawson
 
Posts: n/a
Default Optimiser choice of index


IDS 7.31.FD7
Solaris 9


We have a query that rans in <1 sec using a 2 column composite index (id &
date). I fragmented the table (it was getting close to the 16777215 page
limit) and added another index (date). The query now takes >5 mins to run, a
set explain confirmed the optimiser was using the new index. Adding an
optimiser directive to use the original index solved the problem.

BTW Update Statistics was run after the fragmentation and index build.

My question is this:
Why would the optimiser use the new index on date only when using the index
on id and date is obviously better?

I have a vague recollection about Informix selecting the latest created
index when a column appears in more than one index but can't remember which
version of OnLine it was.

All observations gratefully received




Regards

Colin

There are 10 types of people in the world, those that understand binary and
those that don't
sending to informix-list
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 10:15 AM
scottishpoet
 
Posts: n/a
Default Re: Optimiser choice of index

1/ Bug in the optimiser

2/ The Update Statistics strategy you used did not obtain appropriate
information to provide the optimser with enough detail to choose the
right index

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-20-2008, 10:15 AM
Fernando Nunes
 
Posts: n/a
Default Re: Optimiser choice of index

Colin Dawson wrote:
> IDS 7.31.FD7
> Solaris 9
>
>
> We have a query that rans in <1 sec using a 2 column composite index (id &
> date). I fragmented the table (it was getting close to the 16777215 page
> limit) and added another index (date). The query now takes >5 mins to run, a
> set explain confirmed the optimiser was using the new index. Adding an
> optimiser directive to use the original index solved the problem.
>
> BTW Update Statistics was run after the fragmentation and index build.
>
> My question is this:
> Why would the optimiser use the new index on date only when using the index
> on id and date is obviously better?
>
> I have a vague recollection about Informix selecting the latest created
> index when a column appears in more than one index but can't remember which
> version of OnLine it was.
>
> All observations gratefully received
>
>
>
>
> Regards
>
> Colin
>
> There are 10 types of people in the world, those that understand binary and
> those that don't
> sending to informix-list



One possible reason is some kind of bug.
Another has to do with statistics... Datetimes tend to cause this. You
probably have a lot more occurrences with a certain id than within a
certain time interval.

You could try to increment/decrment the detail of the histograms created
for the second index...

It has to do with estimated costs, and estimated number of rows... as
the name suggests they're just an estimate... not the real thing and
this can lead to situations like this.

Adding 0 seconds to the datetime column may also work around the problem.

Regards.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-20-2008, 10:16 AM
Richard Harnden
 
Posts: n/a
Default Re: Optimiser choice of index

Colin Dawson wrote:
> Colin Dawson wrote:
> IDS 7.31.FD7
> Solaris 9
>
>
> We have a query that rans in <1 sec using a 2 column composite index (id &
> date). I fragmented the table (it was getting close to the 16777215 page
> limit) and added another index (date). The query now takes >5 mins to run, a
> set explain confirmed the optimiser was using the new index. Adding an
> optimiser directive to use the original index solved the problem.
>
> BTW Update Statistics was run after the fragmentation and index build.
>
> My question is this:
> Why would the optimiser use the new index on date only when using the index
> on id and date is obviously better?
>
> I have a vague recollection about Informix selecting the latest created
> index when a column appears in more than one index but can't remember which
> version of OnLine it was.
>
> All observations gratefully received
>
>> The 1st query was after drop and creae of both indexes, 2nd query is after
>> update statistics high for 1st column in all indices and update statistics
>> low for all other columns in all indices
>>
>> QUERY:
>> ------

[snip]
>> where
>> j.cr_date between '2005-09-20 08:00:00' AND
>> '2005-09-20 16:00:00'

^^^^^^^^^^^^^^^^^^^^^

This is a datetime year to second, not a date.

Because the number of values this can take is so finely grained, the
optimiser thinks that it must be highly selective.

--
rh





Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:06 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com