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.96) (envelope-from ) id 1wE9xj-003jVv-0M for pgsql-hackers@arkaria.postgresql.org; Sat, 18 Apr 2026 18:00:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wE9xg-00DSbt-0e for pgsql-hackers@arkaria.postgresql.org; Sat, 18 Apr 2026 18:00:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wE9xf-00DSbl-2I for pgsql-hackers@lists.postgresql.org; Sat, 18 Apr 2026 18:00:07 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wE9xd-00000001egL-17jl for pgsql-hackers@lists.postgresql.org; Sat, 18 Apr 2026 18:00:06 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-5a10d130b37so1647714e87.0 for ; Sat, 18 Apr 2026 11:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776535203; x=1777140003; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=IXqLIKBxmtlrF9dakhE9ATgz4YpspaUa5UTvwQEhpOY=; b=XjQCBXVLk4hA+raT+yHJcucE578eELzhsgoljZlUeJ4/UY+7b7NsNATR8ZXEsh6WtO Xc9HDnWCS30jLA5zSIDahO3nSNF7leSQcP7jNLmhC3DzaWN+BVZA0VPLh4qLjcG+0tEq zM0T0JR8T4XY7D3CZ2Zq2VePCfoAa4Zf+wdcaU1aG2ygc6vkFjLwv/x002hrxE5gEmoW D8fjnlu51HFk3htv2d/pmyfovAhhzujjT8hhsEzLFgaHV1KNq0PAT/aO4u6bR4XXO+Q5 PpAHVwM8J9cJWtcNl6d0KtPSSzChkzGloTWiHeKSYoCfo/tt85q75xPKxznUarKGy0IY Z80g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776535203; x=1777140003; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IXqLIKBxmtlrF9dakhE9ATgz4YpspaUa5UTvwQEhpOY=; b=lbhgFkGjZHEOk5hGEzhS6+yRpkgZ/An5wa0HyrCP0a4oxM0CWa7w5SVc8owxapiqrt J08CDDC4EkIKwx3qzie/VYu//Jbqb87tOKDXzFjI47l69ZO4Y0paOrbpdgAaHQ+83UZ8 5+8Eq+ONyJ8RRU0xzcpzEB5GBS0n4XrhsUQF06i+LQ0ebW7PLhaq60nBeD4+ooX4wXfd atUZfcF5KBjiKfPhu/dQqVcqVgnnjHAb+l1+eSCUllpH/rgImL7pNccqX2PJ5t+du22M XDuatMts7FqhqIPDEeRzd1n7d32T3K6qXLlSAvU9Ay3dOEnHNRfXikK0QlCZOKjNpK5D Na5Q== X-Forwarded-Encrypted: i=1; AFNElJ+re6HQ82GsRoLmtVvSQEDNoywXbdhBqWI0JKJGjFQtd79XnzyvZjtjZoDSxhoD8gUif9BsuL1OksnReC3m@lists.postgresql.org X-Gm-Message-State: AOJu0YyZMULvDlViLRkNY19K0fJGN7RpwwV4kz/Bs7nI8uUoQ4NIFzz2 nDVg887L6D5SI+ZKjYHfCMIt+FPTrax5HpE0Dv251dsq3uQmyAa7KbDg X-Gm-Gg: AeBDietGr+z3gKkRXReUMWwcwRjV91Vm5/DC3KhfmjjlbyOBiGxEqMPdjPThBG8TWeT bgXVQldjYsaBBHcs1CCWnRWtie9lO3xR7ocXUzBmwv385ZhHEhCNEjbU/oDJCKDOcen/RXc+Kjv FXtMubmoseBuOHvZcGrRlZGNmvxxw+BKeuAyMXy6K2RaVIk9iLHiImf0pH8xQTlCDGdaU5e0jE9 ivQcRElDG3AO69tTGe27xSBKMvNd8d2aKoXV5GG8yb9q2Pc5hzNrqS6j9HPXd6QZWeCS8oolUmv rL7GNSAPuv+UayahEH6DyrNfoVyqJT4GR2fllbInXTAnPtKocL2PhqlpznzwnTKKxFUQOFhlIrY c9Ixx16l3avAkWqu7Ayh1iQE+eTLbqg8Spot6ea23uvSBbcwBooPw/Sc2ylbGoAaw+B1rcIKg/E 6q4Sal0mWUl15s03/rYR+3f5VYSo30JAdaGaI= X-Received: by 2002:a05:6512:690:b0:5a4:299:285b with SMTP id 2adb3069b0e04-5a41729996fmr1945146e87.12.1776535202519; Sat, 18 Apr 2026 11:00:02 -0700 (PDT) Received: from [192.168.0.50] ([89.149.68.143]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a4187e7ddbsm1505731e87.63.2026.04.18.11.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 Apr 2026 11:00:01 -0700 (PDT) Message-ID: Date: Sat, 18 Apr 2026 21:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) To: Andres Freund Cc: Melanie Plageman , Tomas Vondra , David Rowley , Kirill Reshke , Chao Li , Andrey Borodin , Xuneng Zhou , Robert Haas , PostgreSQL Hackers , Heikki Linnakangas References: <2be31f17-5405-4de9-8d73-90ebc322f7d8@vondra.me> <97529f5a-ec10-46b1-ab50-4653126c6889@gmail.com> <46733d68-aec0-4d09-8120-4c66b87047a4@gmail.com> Content-Language: en-US From: Alexander Lakhin In-Reply-To: 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 18.04.2026 19:25, Andres Freund wrote: > The interesting column to show here would presumably be relallvisible. > > What I assume is happening is that occasionally analyze now sees enough all > visible pages (due to on-access pruning marking the pages all visible) to > consider the index only scan worthwhile, whereas before that wasn't (or only > very rarely) happened. Indeed, with c.relallvisible added, I can see: --- .../contrib/btree_gist/expected/enum.out        2026-04-18 19:37:51.041565543 +0300 +++ .../contrib/btree_gist/results/enum.out 2026-04-18 19:40:59.077264981 +0300 @@ -88,18 +88,16 @@  where c.relname in ('enumtmp', 'enumidx');   relname | relpages | reltuples | autovacuum_count | autoanalyze_count | relallvisible  ---------+----------+-----------+------------------+-------------------+--------------- - enumtmp |        3 |       595 |                0 |                 0 |             0 + enumtmp |        3 |       595 |                0 |                 0 |             2   enumidx |        4 |       595 | |                   |             0  (2 rows)  EXPLAIN (COSTS OFF)  SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow; -                  QUERY PLAN ------------------------------------------------ +                   QUERY PLAN +------------------------------------------------   Aggregate -   ->  Bitmap Heap Scan on enumtmp -         Recheck Cond: (a >= 'g'::rainbow) -         ->  Bitmap Index Scan on enumidx -               Index Cond: (a >= 'g'::rainbow) -(5 rows) +   ->  Index Only Scan using enumidx on enumtmp +         Index Cond: (a >= 'g'::rainbow) +(3 rows) At 378a21618~1, it stays zero. > Maybe I'm daft, but what would prevent this from happening before? The path > for it would be a bit more complicated, you'd have to have an autovacuum > instead of just an analyze - but that seems possible. It might require running > against a pre-existing install to be likely enough. Yes, with VACUUM enumtmp; instead of ANALYZE enumtmp; the plan change is reproduced at 378a21618~1: @@ -88,18 +88,16 @@  where c.relname in ('enumtmp', 'enumidx');   relname | relpages | reltuples | autovacuum_count | autoanalyze_count | relallvisible  ---------+----------+-----------+------------------+-------------------+--------------- - enumtmp |        3 |       595 |                0 |                 0 |             0 + enumtmp |        3 |       595 |                0 |                 0 |             3   enumidx |        4 |       595 | |                   |             0  (2 rows)  EXPLAIN (COSTS OFF)  SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow; -                  QUERY PLAN ------------------------------------------------ +                   QUERY PLAN +------------------------------------------------   Aggregate -   ->  Bitmap Heap Scan on enumtmp -         Recheck Cond: (a >= 'g'::rainbow) -         ->  Bitmap Index Scan on enumidx -               Index Cond: (a >= 'g'::rainbow) -(5 rows) +   ->  Index Only Scan using enumidx on enumtmp +         Index Cond: (a >= 'g'::rainbow) +(3 rows) And this diff is produced even at f7946a92 (from 2017-03-21), which added the test case. So, given that this is the only failure of btree_gist in two last years at least, it looks like the probability of vacuuming the table there is much lower than of analyzing. >> Could you please look if this can be fixed? > When you say fix, I assume you mean address the test instability, rather than > actual code changes? Sure, I didn't mean the new behavior is wrong. Probably changing that table to temporary would work, but I wonder if there are other queries, which plans can change due to the same reason. Best regards, Alexander