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 B39CD5E46C2 for ; Mon, 30 Aug 2004 13:02:29 -0300 (ADT) 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 47810-02 for ; Mon, 30 Aug 2004 16:02:32 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id 4DB6D5E46F9 for ; Mon, 30 Aug 2004 13:02:22 -0300 (ADT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1C1oc0-0004PY-00 for ; Mon, 30 Aug 2004 18:02:28 +0200 Date: Mon, 30 Aug 2004 18:02:28 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Why does a simple query not use an obvious index? Message-ID: <20040830160228.GB16847@uio.no> References: <1093804128.5493.22.camel@localhost.localdomain> <87fz65k5sq.fsf@stark.xeocode.com> <16093.1093817023@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16093.1093817023@sss.pgh.pa.us> X-Operating-System: Linux 2.6.6 on a i686 User-Agent: Mutt/1.5.6+20040818i 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: 200408/443 X-Sequence-Number: 8079 On Sun, Aug 29, 2004 at 06:03:43PM -0400, Tom Lane wrote: > The expression "now() - something" is not a constant, so the planner > is faced with "timestampfield > unknownvalue". Its default assumption > about the number of rows that will match is much too high to make an > indexscan look profitable (from memory, I think it guesses that about > a third of the table will match...). Out of curiosity, does the subselect query I presented earlier in the thread count as "a constant"? It gives the correct query plan, but this could of course just be correct by accident... /* Steinar */ -- Homepage: http://www.sesse.net/