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 1rn0R6-00B5dA-CQ for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Mar 2024 18:13:12 +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 1rn0R4-0071pO-TR for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Mar 2024 18:13:11 +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 1rn0R4-0071pG-Jd for pgsql-hackers@lists.postgresql.org; Wed, 20 Mar 2024 18:13:11 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rn0R1-005aZ0-Fx for pgsql-hackers@postgresql.org; Wed, 20 Mar 2024 18:13:09 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-414700cffd6so959955e9.1 for ; Wed, 20 Mar 2024 11:13:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1710958386; x=1711563186; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=be+hT5OEeRhMVJY4cANQYyOcq1aUyWZ35cX3f1eXMrU=; b=aBIoP3CyJsDp5mWMxXIuD4SAUhh4eRc1Saf2VjhbvqkNSIKIRQL5L5xWRErkJjAfE+ wvt/FO0I+2lVwyO7lH1+hU1zQA5n76qLNE3bD4Ov/aKkJUxhzyir3OPetVYaxdqFDLkl lye41+66ClE7FNfQanhbQx5oEXVYpUoIU0xDTWzUmzi9PbMDEvKvjtIjVXUyJV+ArpM3 zNMjJCN+gjQwQlqTCBbOIMNhYL1yT071knPIRbFB4kO9HTubuAJtYj2qlXg3MS+OLsSF 8LQ/8RsrKyetpn4GF6wI0pYXEUrqp9+7gfV+vx4FgLM+isvYH9GR6cLq7jLUjLEUs7CE eKDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710958386; x=1711563186; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=be+hT5OEeRhMVJY4cANQYyOcq1aUyWZ35cX3f1eXMrU=; b=Sqwtmuq9IVP0MEgIsf1safll6zd0JOyWoA5mQkMPCrEpi2W0mwlqv9tna4qSc6NaQV 6bv7Ou+IFCCuKeT0GYpOlrSCf59ulmADE2i/FI4K4v68PGjaiJ0nMKylN7R/EUW9cHJJ Cc5FPtisF8/td8G5EC1LxN4viN1DeSMT6G8uF1oj6O9XPGWXguS8JDWnC6kE/vG07rbD 6wysJ7PsTGK+ieI8R1nJso85LW7ZtwKqRtCV/0oI1r4E8mKv18JiY47Qx5jgNTHAxiUl NUf/lAmpZI+36kKVNHX8Ajnjj+ogVF8yCBnSuvlE29E12/qyNHVphDT42gwjxMITijY+ z6ig== X-Forwarded-Encrypted: i=1; AJvYcCWu/R0HIy0Uq44cUuVWreVSAyYzzGkwUwYelND9iRE1VulLprnVBlKim0F4CiHPVvAlUKBXp2byWsBuFsm89nf5JzLZ2c72NtnPy1AK X-Gm-Message-State: AOJu0YxxyWpGSz+0w/fB3OkzLdUYHS+T551v6v8YkHJRki/6XxqOZ9RN JAuwwIYDbaF5FyUtafibWiB7WIkv2EYg8b7fC7964pOKVXwZVjWH9SK6o/EVpw== X-Google-Smtp-Source: AGHT+IHHdOKoNuiRuuSwcDM+erwvyZQkKTvALMiNvvoqgal+p3somXhdKIZ14OLG2WexdgkJyucV5w== X-Received: by 2002:a05:600c:3546:b0:414:ca1:6531 with SMTP id i6-20020a05600c354600b004140ca16531mr2541709wmq.41.1710958385965; Wed, 20 Mar 2024 11:13:05 -0700 (PDT) Received: from [10.137.0.18] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id e13-20020a05600c4e4d00b004146750314csm3000032wmq.3.2024.03.20.11.13.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Mar 2024 11:13:05 -0700 (PDT) Message-ID: <143eb079-0c70-4031-a7b8-ec6aa6e5108b@enterprisedb.com> Date: Wed, 20 Mar 2024 19:13:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BitmapHeapScan streaming read user and prelim refactoring Content-Language: en-US To: Melanie Plageman , Heikki Linnakangas Cc: Andres Freund , Pg Hackers , Thomas Munro , Nazir Bilal Yavuz References: <20240214194228.jf4o7luxtyra5ggv@awork3.anarazel.de> <7c2017c3-f12e-4c43-adad-c5ae0f93cd5d@iki.fi> <20240318151947.uu2il7iegi2gkmol@liskov> From: Tomas Vondra In-Reply-To: <20240318151947.uu2il7iegi2gkmol@liskov> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/18/24 16:19, Melanie Plageman wrote: > On Mon, Mar 18, 2024 at 02:10:28PM +0200, Heikki Linnakangas wrote: >> On 14/02/2024 21:42, Andres Freund wrote: >>> On 2024-02-13 18:11:25 -0500, Melanie Plageman wrote: >>>> patch 0004 is, I think, a bug fix. see [2]. >>> >>> I'd not quite call it a bugfix, it's not like it leads to wrong >>> behaviour. Seems more like an optimization. But whatever :) >> >> It sure looks like bug to me, albeit a very minor one. Certainly not an >> optimization, it doesn't affect performance in any way, only what EXPLAIN >> reports. So committed and backported that to all supported branches. > > I've attached v7 rebased over this commit. > I've started a new set of benchmarks with v7 (on top of f69319f2f1), but unfortunately that results in about 15% of the queries failing with: ERROR: prefetch and main iterators are out of sync Reproducing it is pretty simple (at least on my laptop). Simply apply 0001-0011, and then do this: ====================================================================== create table test_table (a bigint, b bigint, c text) with (fillfactor = 25); insert into test_table select 10000 * random(), i, md5(random()::text) from generate_series(1, 1000000) s(i); create index on test_table(a); vacuum analyze ; checkpoint; set work_mem = '128kB'; set effective_io_concurrency = 8; set random_page_cost = 2; set max_parallel_workers_per_gather = 0; explain select * from test_table where a >= 1 and a <= 512; explain analyze select * from test_table where a >= 1 and a <= 512; ERROR: prefetch and main iterators are out of sync ====================================================================== I haven't investigated this, but it seems to get broken by this patch: v7-0009-Make-table_scan_bitmap_next_block-async-friendly.patch I wonder if there are some additional changes aside from the rebase. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company