Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tOZlR-007HXr-DH for pgsql-performance@arkaria.postgresql.org; Fri, 20 Dec 2024 09:57:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tOZlQ-008RHR-O7 for pgsql-performance@arkaria.postgresql.org; Fri, 20 Dec 2024 09:57:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tOZlQ-008RH0-C2 for pgsql-performance@lists.postgresql.org; Fri, 20 Dec 2024 09:57:44 +0000 Received: from mail1.dalibo.net ([51.159.93.128] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tOZlN-000jX6-3e for pgsql-performance@lists.postgresql.org; Fri, 20 Dec 2024 09:57:43 +0000 Received: from [192.168.0.7] (5-49-10-71.hfc.dyn.abo.bbox.fr [5.49.10.71]) by mail.dalibo.com (Postfix) with ESMTPSA id 73BA926B75; Fri, 20 Dec 2024 10:57:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1734688660; bh=vrECZmY/m8b4Bzo5qd90zJNU29rGYlgjwAkegG4Ouvs=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=SlLiAl/srspxc4ilsSfycDrLrwM5CrLVNKewTSsHFvlnQwZrQcXQV1Dxs/8l8pxrb tIo+Re9d8ND5RlOOszBV/dBEHH+Oai1W6pdBtGP7mOpCdVQ/P5gsck3EKUfWVo/B2F G7h/z5PtZDb4cleVfWGiixCOTrnd0oEKOef/U8lA= Message-ID: <8038b7ca-d4ba-40fb-824b-5f984fb80612@dalibo.com> Date: Fri, 20 Dec 2024 10:57:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Why a bitmap scan in this case? From: =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Yhuel?= To: Jon Zeppieri , Greg Sabino Mullane Cc: pgsql-performance@lists.postgresql.org References: <43c7d623-1805-4db2-a8fc-9a99d3633320@dalibo.com> Content-Language: fr, en-US Autocrypt: addr=frederic.yhuel@dalibo.com; keydata= xjMEXn3bgxYJKwYBBAHaRw8BAQdA6tX5FT/n5ztMWIoBdl6k5avvu65fv6ryfVzIx/aH3V3N JEYuIFlodWVsIDxmcmVkZXJpYy55aHVlbEBkYWxpYm8uY29tPsKWBBMWCAA+FiEEi7OTyf6H ePS+C6n11XGWhN8zGNUFAmZDVJ8CGwMFCQtfi90FCwkIBwIGFQoJCAsCBBYCAwECHgECF4AA CgkQ1XGWhN8zGNV65gEA6o+UrebFjn2CIAOYwP3CiiJugiM5TMH9yJyehQua5ZoA/2ChxiVn 8OUaAw/ErxJmQi1mSN0tNZBL/KhkUPBDUDQNzjgEXn3bgxIKKwYBBAGXVQEFAQEHQCuh5cLQ AtEBXHa2Fmtp0kduBu7msM7qO/gaEcdjFUdiAwEIB8J+BBgWCAAmAhsMFiEEi7OTyf6HePS+ C6n11XGWhN8zGNUFAmZDVJ8FCQtfi90ACgkQ1XGWhN8zGNWOOAEArSqePBqfd4Kx4ulACaWO 6fM+XSDfUlBAQXx9rU6DR4MBALwozl9g91tRysim6lKxggvBfp/PvbpTZNrxYLWB2fYP In-Reply-To: <43c7d623-1805-4db2-a8fc-9a99d3633320@dalibo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/20/24 09:16, Frédéric Yhuel wrote: > > > On 12/19/24 20:09, Jon Zeppieri wrote: >> The table is freshly vacuumed. If I disable bitmap scans, it will do >> an index only scan, which performs better. For the bitmap heap scan, >> it says "Heap Blocks: exact=27393," whereas for the index only scan, >> it's "Heap Fetches: 27701." > > So you have 100% heap fetches. Are you sure that your table is freshly > vacuumed? Please note that VACUUM FULL doesn't create the visibility > map, so you still have to run a plain VACUUM for this. > > And if you still have heap fetches, you could try VACUUM (INDEX_CLEANUP TRUE), so that it doesn't bypass index vacuuming. (In case the pages that contain theses 27701 tuples amount to less than 2% of the total number of pages of the table). Nice explanation here: https://www.cybertec-postgresql.com/en/making-the-postgresql-visibility-map-visible/#vacuum-doesnt-update-the-visibility-map-as-it-should