Re: why is the LIMIT clause slowing down this SELECT?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Mason Hale <masonhale(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: why is the LIMIT clause slowing down this SELECT?
Date: 2007-08-02 00:22:41
Message-ID: 26895.1186014161@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeff Davis <pgsql(at)j-davis(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2007-08-02 00:46:37 Re: why is the LIMIT clause slowing down this SELECT?
Previous Message Gregory Williamson 2007-08-01 23:11:46 List tables in reverse dependancy order