Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g4Ni9-0000Xq-C2 for pgsql-general@arkaria.postgresql.org; Mon, 24 Sep 2018 10:03:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g4Ni7-0004PP-4J for pgsql-general@arkaria.postgresql.org; Mon, 24 Sep 2018 10:03:23 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g4Ni6-0004PI-Pe for pgsql-general@lists.postgresql.org; Mon, 24 Sep 2018 10:03:22 +0000 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g4Ni2-0004Uf-AA for pgsql-general@lists.postgresql.org; Mon, 24 Sep 2018 10:03:21 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 2B997493BC; Mon, 24 Sep 2018 12:03:12 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id PWxjZeq_k70Y; Mon, 24 Sep 2018 12:03:10 +0200 (CEST) Message-ID: <1104a63e897f3c29f44e617f40a33f99a1d80e2c.camel@cybertec.at> Subject: Re: Mysteriously varying index scan costs From: Laurenz Albe To: Pavan Deolasee Cc: pgsql-general@lists.postgresql.org Date: Mon, 24 Sep 2018 12:03:10 +0200 In-Reply-To: References: <0979b9133184be5bdec8a99324854bf95656942f.camel@cybertec.at> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Pavan Deolasee wrote: > On Mon, Sep 24, 2018 at 2:20 PM, Laurenz Albe wrote: > > > > But how can it be that the first run has to touch 74917 blocks, > > while whe second run only needs to touch 1185? > > > > The first index scan may have killed lots of index tuples. So the first index scan visited lots of table tuples, found them dead, and set the LP_DEAD flag on the corresponding index items so that subsequent index scans could ignore them, right? Thanks, that must be the correct explanation. It correlates nicely with the dirtied pages, too. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com