X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 593AAD1B1F8 for ; Fri, 23 Jul 2004 11:46:47 -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 66661-06 for ; Fri, 23 Jul 2004 14:46:53 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0861DD1B182 for ; Fri, 23 Jul 2004 11:46:43 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6NEjR3F020163; Fri, 23 Jul 2004 10:45:29 -0400 (EDT) To: Dennis Bjorklund Cc: Gaetano Mendola , "pgsql-hackers@postgresql.org" Subject: Re: Wrong index choosen? In-reply-to: References: Comments: In-reply-to Dennis Bjorklund message dated "Fri, 23 Jul 2004 14:01:56 +0200" Date: Fri, 23 Jul 2004 10:45:27 -0400 Message-ID: <20162.1090593927@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: 200407/1138 X-Sequence-Number: 56699 Dennis Bjorklund writes: > In this plan it estimates to get 481 but it got 22477. So the estimation > was very wrong. You can increase the statistics tarhet on the login_time > and it will probably be better (after the next analyze). Given the nature of the data (login times), I'd imagine that the problem is simply that he hasn't analyzed recently enough. A bump in stats target may not be needed, but he's going to have to re-analyze that column often if he wants this sort of query to be estimated accurately, because the fraction of entries later than a given time T is *always* going to be changing. regards, tom lane