Re: Query planning around one key of a multi-column index

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Re: Query planning around one key of a multi-column index
Дата
Msg-id CAMkU=1wA=nrugoa5sbgCBbcpT2azDbzoZLc6F7Myj4e=azhNiA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Query planning around one key of a multi-column index  (Wells Oliver <wells.oliver@gmail.com>)
Список pgsql-admin
On Wed, Dec 18, 2019 at 11:19 PM Wells Oliver <wells.oliver@gmail.com> wrote:
But so are you guys!

Thanks, this is helpful.

Is it really always true that querying off any column that's not the first column of a multi-column index will NOT use that index?

Are you talking only about btree indexes?  Those are certainly the most common, but other index types exist and have other properties.

Anyway, it is not always true for btree indexes.  The planner might decide to use the index as a skinny version of the table, and scan the full index to extract some non-leading column from it.  How likely it is to do this will depend mainly on how much smaller the index is than the table, and your relative settings of seq_page_cost and random_page_cost.  (Unlike some other products, PostgreSQL will scan the index in logical order, not physical order, even though it doesn't care about the order and this generates a more random IO pattern, because this is the only practical way to protect against concurrent page splits while it scans).  Unfortunately, the EXPLAIN output does not make it clear when a index is being used in this way, rather than the more traditional way.

Cheers,

Jeff

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Problem with Altering a table column
Следующее
От: Pepe TD Vo
Дата:
Сообщение: Re: backup script error with could not connect to database