Re: Index ot being used

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Index ot being used
Дата
Msg-id 24636.1118591783@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Index ot being used  (Madison Kelly <linux@alteeve.com>)
Ответы Re: Index ot being used
Список pgsql-performance
Madison Kelly <linux@alteeve.com> writes:
>    Here is my full query:

> tle-bu=> EXPLAIN ANALYZE SELECT file_name, file_parent_dir, file_type
> FROM file_info_7 WHERE file_type='d' ORDER BY file_parent_dir ASC,
> file_name ASC;

>    This is my index (which I guess is wrong):

> tle-bu=> \d file_info_7_display_idx
>   Index "public.file_info_7_display_idx"
>       Column      |         Type
> -----------------+----------------------
>   file_type       | character varying(2)
>   file_parent_dir | text
>   file_name       | text
> btree, for table "public.file_info_7"

The index is fine, but you need to phrase the query as

    ... ORDER BY file_type, file_parent_dir, file_name;

(Whether you use ASC or not doesn't matter.)  Otherwise the planner
won't make the connection to the sort ordering of the index.

            regards, tom lane

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

Предыдущее
От: Madison Kelly
Дата:
Сообщение: Re: Index ot being used
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: Index ot being used