Re: Optimizing No matching record Queries

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Stephen Denne" <Stephen(dot)Denne(at)datamail(dot)co(dot)nz>
Cc: "Pallav Kalva" <pkalva(at)livedatagroup(dot)com>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Optimizing No matching record Queries
Date: 2008-02-13 00:16:44
Message-ID: 87r6fhaexf.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"Stephen Denne" <Stephen(dot)Denne(at)datamail(dot)co(dot)nz> writes:

> Pallav Kalva asked
> ...
>> and listing0_.fklistingsourceid=5525
> ...
>> order by listing0_.entrydate desc limit 10;
>
>> -> Index Scan Backward using idx_listing_entrydate on
>> listing listing0_ (cost=0.00..781557.28 rows=5118 width=107) (actual
>> time=2113544.412..2113544.412 rows=0 loops=1)
>> Filter: (fklistingsourceid = 5525)
>
> Would it help to have a combined index on fklistingsourceid, entrydate?

I think that would help. You already have a ton of indexes, you might consider
whether all your queries start with a listingsourceid and whether you can have
that as a prefix on the existing index.

Another thing to try is raising the stats target on fklistingsourceid and/or
entrydate. The estimate seems pretty poor. It could just be that the
distribution is highly skewed which is a hard case to estimate correctly.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's RemoteDBA services!

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Richard Huxton 2008-02-13 08:54:48 Re: Optimizing No matching record Queries
Previous Message Dean Gibson (DB Administrator) 2008-02-13 00:07:29 Re: Optimizing No matching record Queries