Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id B7BD413364DE for ; Mon, 17 Jan 2011 16:57:28 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 79717-02 for ; Mon, 17 Jan 2011 20:57:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 453FC133616B for ; Mon, 17 Jan 2011 16:57:21 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p0HKvK6u020745; Mon, 17 Jan 2011 15:57:20 -0500 (EST) To: Tim Uckun cc: Robert Haas , pgsql-bugs@postgresql.org Subject: Re: Problems with adding a is not null to a query. In-reply-to: References: <28545.1295106303@sss.pgh.pa.us> <9026.1295198134@sss.pgh.pa.us> Comments: In-reply-to Tim Uckun message dated "Tue, 18 Jan 2011 02:23:56 +1300" Date: Mon, 17 Jan 2011 15:57:20 -0500 Message-ID: <20744.1295297840@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201101/127 X-Sequence-Number: 29149 Tim Uckun writes: > relname | pg_relation_size | reltuples | relpages > ------------------------+------------------+-------------+---------- > consolidated_urls | 1303060480 | 1.80192e+06 | 159065 > consolidated_urls_pkey | 114745344 | 1.80192e+06 | 14007 With a table that large, you're probably going to need a larger stats target in order to get reasonable estimates for low-frequency values. Am I right in guessing that pg_stats.n_distinct is much too low for the domain_id column? regards, tom lane