Re: Postgres Query Plan using wrong index

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Postgres Query Plan using wrong index
Дата
Msg-id 702947.1743553839@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Postgres Query Plan using wrong index  (Manikandan Swaminathan <maniswami23@gmail.com>)
Список pgsql-general
Manikandan Swaminathan <maniswami23@gmail.com> writes:
> 4. When running the following query, I would expect the index "idx_col_b_a"
> to be used: select min(col_b) from test_table  where col_a > 4996.
> I have a range-based filter on col_a, and am aggregating the result with
> min(col_b). Both columns are covered by "idx_col_b_a".

They may be covered, but sort order matters, and that index has the
wrong sort order to help with this query.  Try

create index on test_table(col_b, col_a);

            regards, tom lane



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