Re: Query with order by and limit is very slow - wrong index used

From: Gregg Jaskiewicz <gryzman(at)gmail(dot)com>
To: Nowak Michał <michal(dot)nowak(at)me(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Query with order by and limit is very slow - wrong index used
Date: 2011-10-03 10:02:26
Message-ID: CAJY59_jGxvDnr0RsU9+Sn8kdOYL2TqHLtNdtDCyP77dF=Ki4Gg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

How many rows do you have in that table?

I think , that planner thinks that the element you are looking for is
so common - that it will be to expensive to use index to fetch it.
Perhaps try increasing default_statistics_target , and revacuuming the table.

You could also try changing it just for the column:

ALTER TABLE records ALTER id SET source_id 1000; vacuum analyze verbose records;

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Nowak Michał 2011-10-03 10:51:52 Re: Query with order by and limit is very slow - wrong index used
Previous Message Nowak Michał 2011-10-03 09:44:21 Query with order by and limit is very slow - wrong index used