Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 67B7A64FC22 for ; Tue, 23 Sep 2008 22:13:40 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 68661-06 for ; Tue, 23 Sep 2008 22:13:37 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.61.230.242]) by postgresql.org (Postfix) with ESMTP id CE3FB64FC04 for ; Tue, 23 Sep 2008 22:13:37 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id 22D3A5C0C5; Wed, 24 Sep 2008 09:13:33 +0800 (WST) Received: from localhost (access [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 0F0F31E0435; Wed, 24 Sep 2008 09:13:33 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (access.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ebqO-C5cPawj; Wed, 24 Sep 2008 09:13:32 +0800 (WST) Received: from [192.168.44.89] (203-59-94-220.perm.iinet.net.au [203.59.94.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTP id 659971E0434; Wed, 24 Sep 2008 09:13:32 +0800 (WST) Message-ID: <48D9943B.9060801@postnewspapers.com.au> Date: Wed, 24 Sep 2008 09:13:31 +0800 From: Craig Ringer User-Agent: Thunderbird 2.0.0.16 (X11/20080725) MIME-Version: 1.0 To: Einars Cc: pgsql-performance@postgresql.org Subject: Re: Chaotically weird execution plan References: <4f8bd5c90809231753xbcdacd2xfba4d38c2eb34faf@mail.gmail.com> In-Reply-To: <4f8bd5c90809231753xbcdacd2xfba4d38c2eb34faf@mail.gmail.com> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/206 X-Sequence-Number: 31519 Einars wrote: > As query plan shows, it got the > correct answer, 15888, very fast: the rest of the 13 seconds it's just > rechecking all the comments for some weird reasons. I'd already written: "If you need the test for status = 1, consider a partial index" when I noticed your schema definition: > "comments_created_by" btree (created_by) WHERE status = 1 I find it hard to guess why it's having to recheck the WHERE clause given the use of a partial index that should cover that nicely. I don't see how it could be a visibility issue (in that I thought tuples were read and tested for visibility as part of the initial heap scan) but I don't see what else it could be. It seems odd to me, so I'm really interested in seeing what others have to say on this. -- Craig Ringer