Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 635AF2E15C5 for ; Wed, 13 Feb 2008 04:54:55 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 39931-06 for ; Wed, 13 Feb 2008 04:54:51 -0400 (AST) Received: from pih-relay08.plus.net (pih-relay08.plus.net [212.159.14.134]) by postgresql.org (Postfix) with ESMTP id 93E632E15CB for ; Wed, 13 Feb 2008 04:54:51 -0400 (AST) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by pih-relay08.plus.net with esmtp (Exim) id 1JPDOD-0000Mj-4E; Wed, 13 Feb 2008 08:54:49 +0000 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 7F2B5274060; Wed, 13 Feb 2008 08:54:48 +0000 (GMT) Message-ID: <47B2B058.7020804@archonet.com> Date: Wed, 13 Feb 2008 08:54:48 +0000 From: Richard Huxton User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: "Dean Gibson (DB Administrator)" CC: pgsql-performance@postgresql.org Subject: Re: Optimizing No matching record Queries References: <47B2112C.5070707@livedatagroup.com> <47B234C1.1090707@ultimeth.com> In-Reply-To: <47B234C1.1090707@ultimeth.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Plusnet-Relay: c508dec954eb2a9b4f2e02d066646fe9 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/126 X-Sequence-Number: 28668 Dean Gibson (DB Administrator) wrote: > The questions are: > > 1. Why in the planner scanning the entire idx_listing_entrydate, when > I'd think it should be scanning the entire > pk_listingstatus_listingstatusid ? It's looking at the ORDER BY and sees that the query needs the 10 most recent, so tries searching by date. That's sensible where you are going to have a lot of matches for fklistingsourceid. Which suggests that statistics for "fklistingsourceid" aren't high enough, like Greg suggested. If that doesn't help, the index on (fklistingsourceid,entrydate) that Stephen might well do so. > 2. Why is "Index Scan using pk_listingstatus_listingstatusid on > listingstatus listingsta1_ (cost=0.00..0.27 rows=1 width=4) (never > executed)" ? Because nothing comes out of the first index-scan. -- Richard Huxton Archonet Ltd