Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id C6ABA632796 for ; Mon, 15 Feb 2010 13:24:39 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 48596-02 for ; Mon, 15 Feb 2010 17:24:19 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.24]) by mail.postgresql.org (Postfix) with ESMTP id E5C3A6326E2 for ; Mon, 15 Feb 2010 13:24:28 -0400 (AST) Received: by ey-out-2122.google.com with SMTP id 25so608699eya.33 for ; Mon, 15 Feb 2010 09:24:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=o5Yz0jJiv5l15cjqZuazeC00M7YxL2AKlSRZEZzSt7Y=; b=A3Z7dK1BaW2fhXjVUNMqRvFBpvzI+44nYGftYuUhnLa35cxqhD4c7R+9rys9jyVk54 VLpT1svMTpPmbrYZOcyWtELkTYyFxj3LutMnw0WhkulJyqs8GOx9SrnKsnV4tnjv81Pu BtZbdCfInLtI/b/YmQPCSy/XKGqOdpWNd7rvA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=gK6r/60bHls199K3Xlc3Uf2g0b/85jitwmuZHTwwlwzUzqARyJZUno4RzVTXMr64jU QWcqB5LQbpDpOn50FvSvvHZGWGVn0KV2zQR1Vy5mfrAb74sI6/49V8cSrzkChbQv15eE uV0ac+7CQoVh/yDPSR9BBfn9GXUcWqtOH752A= MIME-Version: 1.0 Received: by 10.216.172.203 with SMTP id t53mr3225511wel.56.1266254667116; Mon, 15 Feb 2010 09:24:27 -0800 (PST) In-Reply-To: <4B791971.6020804@boozter.com> References: <4B755913.7090004@boozter.com> <4B7519C5020000250002F242@gw.wicourts.gov> <4B75BADE.9030906@boozter.com> <4B756CE5020000250002F27C@gw.wicourts.gov> <4B791971.6020804@boozter.com> Date: Mon, 15 Feb 2010 10:24:27 -0700 Message-ID: Subject: Re: Almost infinite query -> Different Query Plan when changing where clause value From: Scott Marlowe To: lionel duboeuf Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.408 tagged_above=-10 required=5 tests=AWL=0.191, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/242 X-Sequence-Number: 37663 On Mon, Feb 15, 2010 at 2:52 AM, lionel duboeuf wrote: > See as attachment the "correct" query plan for an other 'user'. > I confirm by executing manual "VACUUM ANALYZE" that the problem is solved. > But what i don't understand is that i would expect autovacuum to do the job. There are two operations here. Vacuum, which reclaims lost space, and analyze which analyzes your data and stores histograms to be used when building queries, to determine how many rows are likely to be returned by each part of the plan. The autovac daemon runs both vacuums and analyzes, often independently of each other, when needed, based on threshold settings. By running autovac your db would get analyzed when necessary and would then have up to date statistics when queries were run after that.