How does postgres behave if several indexes have (nearly) identical conditions?

Поиск
Список
Период
Сортировка
От Koen De Groote
Тема How does postgres behave if several indexes have (nearly) identical conditions?
Дата
Msg-id CAGbX52HAf7EdeNNrHGMGLFdftiY6-jUnayRaEt5a5cR2E56sRQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: How does postgres behave if several indexes have (nearly) identical conditions?  (Koen De Groote <kdg.dev@gmail.com>)
Re: How does postgres behave if several indexes have (nearly) identical conditions?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
Greetings all.

Example table:

CREATE TABLE my_table (
    id serial PRIMARY KEY,
    a001 BOOLEAN default 't',
    a002 BOOLEAN default 'f',
    a003 BOOLEAN default 't',
    a004 BOOLEAN default 'f'
);

And these 2 indexes:

create index index_001 on my_table using btree (a001,a002,a003) where a001=true and a002=false;

create index index_002 on my_table using btree (a003) where a001=true and a002=false;

Now take this query:

select * from my_table where a001=true;

Which index will postgres pick? I'm wondering how postgres goes about picking an index to consider.

And if it will consider others if the analysis of the first says a seqscan would be better than the index it first considered?

Regards,
Koen De Groote

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

Предыдущее
От: Miles Elam
Дата:
Сообщение: Re: Logical Replication to Older Version
Следующее
От: Koen De Groote
Дата:
Сообщение: Re: How does postgres behave if several indexes have (nearly) identical conditions?