X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 303793A3E76 for ; Fri, 5 Nov 2004 20:32:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51111-06 for ; Fri, 5 Nov 2004 20:32:32 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9DD673A3E5F for ; Fri, 5 Nov 2004 20:32:31 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA5KWSYa011492; Fri, 5 Nov 2004 15:32:29 -0500 (EST) To: matt@followers.net Cc: Postgresql Performance Subject: Re: What is the difference between these? In-reply-to: <27c475ec0411051009460dd9d0@mail.gmail.com> References: <27c475ec0411051009460dd9d0@mail.gmail.com> Comments: In-reply-to Matt Nuzum message dated "Fri, 05 Nov 2004 13:09:26 -0500" Date: Fri, 05 Nov 2004 15:32:28 -0500 Message-ID: <11491.1099686748@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/109 X-Sequence-Number: 9063 Matt Nuzum writes: > To me, these three queries seem identical... why doesn't the first one > (simplest to understand and write) go the same speed as the third one? This is the standard problem that the planner has to guess about the selectivity of inequalities involving non-constants (like now()). The guesses are set up so that a one-sided inequality will use a seqscan while a range constraint will use an indexscan. See the pgsql-performance archives for other ways of persuading it that an indexscan is a good idea. regards, tom lane