Re: function indexes, index only scan and sorting

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: function indexes, index only scan and sorting
Дата
Msg-id 9367.1418421517@sss.pgh.pa.us
обсуждение исходный текст
Ответ на function indexes, index only scan and sorting  (Jonathan Vanasco <postgres@2xlp.com>)
Ответы Re: function indexes, index only scan and sorting  (Jonathan Vanasco <postgres@2xlp.com>)
Список pgsql-general
Jonathan Vanasco <postgres@2xlp.com> writes:
> Am I correct in observing that the value of a function index can't be used for sorting ?

No ...

regression=# create table tt (f1 int, f2 text);
CREATE TABLE
regression=# create index on tt (lower(f2));
CREATE INDEX
regression=# explain select * from tt order by lower(f2);
                                 QUERY PLAN
----------------------------------------------------------------------------
 Index Scan using tt_lower_idx on tt  (cost=0.15..65.68 rows=1230 width=36)
(1 row)

Now, whether the planner will prefer this over seqscan-and-sort is a
much harder question.  Full-table index scans tend to require a lot
of random I/O so a sort is frequently seen as cheaper.

            regards, tom lane


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

Предыдущее
От: Jonathan Vanasco
Дата:
Сообщение: Re: Removing duplicate records from a bulk upload (rationale behind selecting a method)
Следующее
От: Jonathan Vanasco
Дата:
Сообщение: Re: function indexes, index only scan and sorting