Re: Indexes intersection

Поиск
Список
Период
Сортировка
От Jim C. Nasby
Тема Re: Indexes intersection
Дата
Msg-id 20030408191607.S31861@flake.decibel.org
обсуждение исходный текст
Ответ на Indexes intersection  ("Roberto de Amorim" <rbamorim@ig.com.br>)
Список pgsql-general
On Mon, Apr 07, 2003 at 03:25:31PM -0300, Roberto de Amorim wrote:
> for example: I have 2 indexes, the first in on (date_inclusion ,
> date_cancellation ) and the other is in (date_cancellation ,
> date_inclusion ).
>
> so, when I do a query like this:
> select * from mytable
> where (date_inclusion <= '01/01/2003') and (date_cancellation >
> '01/01/2003')
>
> I think that PostgreSQL should use those 2 indexes and do an intersection
> automatically between they

I think you're not asking the question quite right. :) In this case, it
will use one index or the other, because both indexes contain both
fields. I'm guessing what you want to know is if you had two indexes

create index index_a on mytable(date_inclusion)
create index index_a on mytable(date_cancellation)

would the query you show use both indexes, or would it just pick one.

I don't know the answer, but would like to. :)
--
Jim C. Nasby (aka Decibel!)                    jim@nasby.net
Member: Triangle Fraternity, Sports Car Club of America
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"


В списке pgsql-general по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Yet Another (Simple) Case of Index not used
Следующее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: How does PostgreSQL treat null values in unique composite