Re: BUG #2658: Query not using index

From: Chris Browne <cbbrowne(at)acm(dot)org>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: BUG #2658: Query not using index
Date: 2006-10-03 19:02:32
Message-ID: 60irj1gr3r.fsf@dba2.int.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-performance

gdavis(at)refractions(dot)net (Graham Davis) writes:
> Adding DESC to both columns in the SORT BY did not make the query use
> the multikey index. So both
>
> SELECT DISTINCT ON (assetid) assetid, ts
> FROM asset_positions ORDER BY assetid, ts DESC;
>
> and
>
> SELECT DISTINCT ON (assetid) assetid, ts
> FROM asset_positions ORDER BY assetid DESC, ts DESC;
>
> use the same query plans and both do sequential scans without using
> either the (assetid, ts) or (ts) indexes. Any other ideas on how to
> make this query use an index? Thanks,

Why do you want to worsen performance by forcing the use of an index?

You are reading through the entire table, after all, and doing so via
a sequential scan is normally the fastest way to do that. An index
scan would only be more efficient if you don't have enough space in
memory to store all assetid values.
--
(reverse (concatenate 'string "gro.mca" "@" "enworbbc"))
http://www3.sympatico.ca/cbbrowne/emacs.html
Expect the unexpected.
-- The Hitchhiker's Guide to the Galaxy, page 7023

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Martin 2006-10-03 19:03:49 BUG #2673: run-time error '429'
Previous Message ragetron99 2006-10-03 18:39:00 BUG #2672: stored procedure argument and return type length validation

Browse pgsql-performance by date

  From Date Subject
Next Message Graham Davis 2006-10-03 19:10:49 Re: BUG #2658: Query not using index
Previous Message Graham Davis 2006-10-03 18:20:49 Re: BUG #2658: Query not using index