Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gL94T-0004nU-Hh for pgsql-general@arkaria.postgresql.org; Fri, 09 Nov 2018 15:51:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gL94S-0005iH-2t for pgsql-general@arkaria.postgresql.org; Fri, 09 Nov 2018 15:51:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gL94R-0005iA-N6 for pgsql-general@lists.postgresql.org; Fri, 09 Nov 2018 15:51:43 +0000 Received: from mx1.mailbox.org ([80.241.60.212]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gL94O-0002IW-A4 for pgsql-general@postgresql.org; Fri, 09 Nov 2018 15:51:42 +0000 Received: from smtp1.mailbox.org (unknown [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 6F5E54B06D; Fri, 9 Nov 2018 16:51:36 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id LK4bINcIeadm; Fri, 9 Nov 2018 16:51:35 +0100 (CET) Message-ID: <3053c9cec512260c53e4f48cab370a295b6ff4af.camel@cybertec.at> Subject: Re: index only scan question From: Laurenz Albe To: Daniel Westermann , "pgsql-general@postgresql.org" Date: Fri, 09 Nov 2018 16:51:33 +0100 In-Reply-To: References: ,<96183def4b971c718367fdbc6021f6b9706f03ea.camel@cybertec.at> , Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Daniel Westermann wrote: > >I'd say the old index tuple was killed during the first scan: > >https://www.cybertec-postgresql.com/en/killed-index-tuples/ > > ... from your blog: "Whenever an index scan fetches a heap tuple only to find that it is dead > (that the entire “HOT chain” of tuples is dead, to be more precise), it marks the index tuple > as “killed”. Then future index scans can simply ignore it. > > I understand that, but in my case the chain is not dead so this does not explain the difference. > Do I miss something? I assume that the UPDATE was not HOT, because the first scan had to fetch two tuples. After the UPDATE, the original tuple was dead (the HOT chain consists only of a single tuple here, because it was no HOT update). The first index scan detects that and marks the index tuple as killed. The second index scan only visits the new tuple. Yours, Laurenz Albe