Re: why is the LIMIT clause slowing down this SELECT? - Mailing list pgsql-general

From Tom Lane
Subject Re: why is the LIMIT clause slowing down this SELECT?
Date
Msg-id 26895.1186014161@sss.pgh.pa.us
Whole thread Raw
In response to Re: why is the LIMIT clause slowing down this SELECT?  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-general
Jeff Davis <pgsql@j-davis.com> writes:
> On Wed, 2007-08-01 at 15:56 -0500, Mason Hale wrote:
>> SELECT *
>> FROM topic_feed
>> WHERE topic_id = 106947234
>> ORDER BY score DESC
>> LIMIT 25

> In plan 1, the planner thinks that it will find 25 tuples matching that
> topic_id quickly during the backwards index scan on
> topic_feed_score_index. Instead, it looks like it has to go through a
> lot of tuples before it finds the necessary 25.

Yeah.  An index on (topic_id, score) would perhaps be helpful.

            regards, tom lane

pgsql-general by date:

Previous
From: Reid Thompson
Date:
Subject: Re: Linux distro
Next
From: "Scott Marlowe"
Date:
Subject: Re: why is the LIMIT clause slowing down this SELECT?