Subject | Re: [firebird-support] Index not used by "where xxx not null" query? |
---|---|
Author | Nando Dessena |
Post date | 2006-02-27T15:19:39Z |
Kjell,
KR> OK, in that case I see two possible reasons for what I'm seeing. Either
KR> 1) FB sorts nulls at the end of the index regardless of asc/desc and
KR> since an index can't be traversed backwards it cannot be used for "is
KR> not null", or
KR> 2) FB sorts nulls at the beginning of the index regardless of asc/desc
KR> and could possibly use it for "is not null", but for some reason does not.
it's the other way around. If nulls are at the beginning then an index
can be used for "is null". And that's actually the state of affairs
(your case 2, I mean) I think.
KR> If it's 2 then it would be interesting to know why the index isn't used,
It is. :-)
--
Nando Dessena
http://www.flamerobin.org
KR> OK, in that case I see two possible reasons for what I'm seeing. Either
KR> 1) FB sorts nulls at the end of the index regardless of asc/desc and
KR> since an index can't be traversed backwards it cannot be used for "is
KR> not null", or
KR> 2) FB sorts nulls at the beginning of the index regardless of asc/desc
KR> and could possibly use it for "is not null", but for some reason does not.
it's the other way around. If nulls are at the beginning then an index
can be used for "is null". And that's actually the state of affairs
(your case 2, I mean) I think.
KR> If it's 2 then it would be interesting to know why the index isn't used,
It is. :-)
--
Nando Dessena
http://www.flamerobin.org