From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
Cc: | Lists <lists(at)on-track(dot)ca>, Josh Berkus <josh(at)agliodbs(dot)com>, postgres performance list <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Shouldn't the planner have a higher cost for reverse index scans? |
Date: | 2009-04-16 15:36:34 |
Message-ID: | 18553.1239896194@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
> On Thu, Apr 16, 2009 at 2:02 AM, Lists <lists(at)on-track(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-04-16 15:42:43 | Re: Shouldn't the planner have a higher cost for reverse index scans? |
Previous Message | Merlin Moncure | 2009-04-16 14:44:03 | Re: Really dumb planner decision |