Re: Shouldn't the planner have a higher cost for reverse index scans?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Shouldn't the planner have a higher cost for reverse index scans?
Дата
Msg-id 18553.1239896194@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Shouldn't the planner have a higher cost for reverse index scans?  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-performance
Merlin Moncure <mmoncure@gmail.com> writes:
> On Thu, Apr 16, 2009 at 2:02 AM, Lists <lists@on-track.ca> wrote:
>> select comment_date
>>     from user_comments
>>     where user_comments.uid=1
>>     order by comment_date desc limit 1

> try this:
> create index comment_data_uid_idx on user_comments(uid, comment_date);

> select * from user_comments where (uid, comment_date) < (1, high_date)
>   order by uid desc, comment_date desc limit 1;

You don't really need to complicate your queries like that.  Having the
two-column index will suffice to make the given query work fine, at
least in reasonably modern PG versions (since 8.1 I think).

            regards, tom lane

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

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: Really dumb planner decision
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Shouldn't the planner have a higher cost for reverse index scans?