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 1ra6yg-0087I8-Am for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Feb 2024 04:34:34 +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 1ra6yb-003qDC-Dw for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Feb 2024 04:34:29 +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 1ra6yb-003qCw-3M for pgsql-hackers@lists.postgresql.org; Wed, 14 Feb 2024 04:34:29 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1ra6yX-0075wB-AK for pgsql-hackers@postgresql.org; Wed, 14 Feb 2024 04:34:28 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6e0507eb60cso3305059b3a.3 for ; Tue, 13 Feb 2024 20:34:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1707885261; x=1708490061; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NLWUIRbXYGfKhKwSzXbdONkPsu7Xjig5KoRLkC8CHZs=; b=c9fd1uLxh6iyAyy5onc6XczQwaZUyABZke4nq5DzJK1VFLq6iHZFrFfUriGAXP1eta d3tih5xkOBXJXFr1ktx4WoqNHEW0vzsWlfTLJz1YaeMLFMABClkd9oshm4ZhDM2tS1VW 4wZbB6FaDBMM9yvlQP+6mBVGk/RXuEGus+KNgqWyK0YmGt7T42S4sQWM/+bzO1kQQN5k U+j5P5ocwICptb/dvdR1kEDW5V8FxNmzPCVImUugAf9hzoWFD+Ov02X+pa8dgON1+YYY wL/pVZ6HWYMufl+FzcNK8HxywBZBf7HMNG/wNgLwTyLhGq16JY1PNg2O/tJ0Cm7oNM3a w7Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707885261; x=1708490061; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NLWUIRbXYGfKhKwSzXbdONkPsu7Xjig5KoRLkC8CHZs=; b=O6v0I14H1AjzH0XCZYQb3SoN8I+FM0TUaMip+Ay2rQ9eemu0UFYjIIxYalHnnPdmCV RxlnOqUmVlmO3NG7vzOY41wIGyR6V9SRzRkFsAxiuH+C0LPON786R49c/aEQuOL6i6vO YCG3bsmYKPCrM8PPsEz0u8Wa4/sovu3Pa8/1DecjIOBC7h5uE2Qf1A9ucHeN3nueT0Zz T07wf4xxDA0AOO1lJfhF5UEgnlNYBgaAak/bOSkoN6ZaMEPVJlK+EezNu7qKSJ49fS30 n/qvLrlXKNyBg1vyZMykjj20U798hlRjLFUG46pl4sFPxxW/Sd80pFXzZLWtwIdAlFNX DIpg== X-Gm-Message-State: AOJu0Yw5DWFEgZXKzGao1xDjk84m4r5XczhJqZkZZYw8Gg0z5g80wqiT vJPF8ZkWxO0Abt16hzRelnRf5wa9mxLt/YMbkufkQ3h2ieMCXyG7p++40iRNBg== X-Google-Smtp-Source: AGHT+IG5pODLXTk7bmlCHFigPDjth78g0fOSM1CDMiZ+HiSppXQ1YYeGPqjDzSdiC3A86ONgX/1ojA== X-Received: by 2002:a05:6a00:13a2:b0:6e1:dbd:e800 with SMTP id t34-20020a056a0013a200b006e10dbde800mr379432pfg.17.1707885261667; Tue, 13 Feb 2024 20:34:21 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV3T9ekyXHB3zKgYYJqyq3IU8qDM6399EsmO1pIU9X//u9fZkfXkr07w/EzUuKaALtPxtMZj9Q5nKk5/di/31henHK/Pbq5bXlYy7mYfqAPkCJMPWAmeY580n52LANYqkYpVxr5giV0JCX/Qwv0dcSGfz0X2PbDer+eXhYp3jkm Received: from smtpclient.apple (24-113-193-150.wavecable.com. [24.113.193.150]) by smtp.gmail.com with ESMTPSA id f7-20020a056a00238700b006e089bb3619sm8165500pfc.112.2024.02.13.20.34.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2024 20:34:21 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: BitmapHeapScan streaming read user and prelim refactoring From: Mark Dilger In-Reply-To: Date: Tue, 13 Feb 2024 20:34:20 -0800 Cc: Pg Hackers , Andres Freund , Thomas Munro , Heikki Linnakangas , Nazir Bilal Yavuz Content-Transfer-Encoding: quoted-printable Message-Id: <8DE07ADE-1D86-4680-8793-057FAAE35B5C@enterprisedb.com> References: To: Melanie Plageman X-Mailer: Apple Mail (2.3731.700.6) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Feb 13, 2024, at 3:11 PM, Melanie Plageman = wrote: Thanks for the patch... > Attached is a patch set which refactors BitmapHeapScan such that it > can use the streaming read API [1]. It also resolves the long-standing > FIXME in the BitmapHeapScan code suggesting that the skip fetch > optimization should be pushed into the table AMs. Additionally, it > moves table scan initialization to after the index scan and bitmap > initialization. >=20 > patches 0001-0002 are assorted cleanup needed later in the set. > patches 0003 moves the table scan initialization to after bitmap = creation > patch 0004 is, I think, a bug fix. see [2]. > patches 0005-0006 push the skip fetch optimization into the table AMs > patches 0007-0009 change the control flow of BitmapHeapNext() to match > that required by the streaming read API > patch 0010 is the streaming read code not yet in master > patch 0011 is the actual bitmapheapscan streaming read user. >=20 > patches 0001-0009 apply on top of master but 0010 and 0011 must be > applied on top of a commit before a 21d9c3ee4ef74e2 (until a rebased > version of the streaming read API is on the mailing list). I followed your lead and applied them to = 6a8ffe812d194ba6f4f26791b6388a4837d17d6c. `make check` worked fine, = though I expect you know that already. > The caveat is that these patches introduce breaking changes to two > table AM functions for bitmapheapscan: table_scan_bitmap_next_block() > and table_scan_bitmap_next_tuple(). You might want an independent perspective on how much of a hassle those = breaking changes are, so I took a stab at that. Having written a custom = proprietary TAM for postgresql 15 here at EDB, and having ported it and = released it for postgresql 16, I thought I'd try porting it to the the = above commit with your patches. Even without your patches, I already = see breaking changes coming from commit = f691f5b80a85c66d715b4340ffabb503eb19393e, which creates a similar amount = of breakage for me as does your patches. Dealing with the combined = breakage might amount to a day of work, including testing, half of which = I think I've already finished. In other words, it doesn't seem like a = big deal. Were postgresql 17 shaping up to be compatible with TAMs written for 16, = your patch would change that qualitatively, but since things are already = incompatible, I think you're in the clear. > A TBMIterateResult used to be threaded through both of these functions > and used in BitmapHeapNext(). This patch set removes all references to > TBMIterateResults from BitmapHeapNext. Because the streaming read API > requires the callback to specify the next block, BitmapHeapNext() can > no longer pass a TBMIterateResult to table_scan_bitmap_next_block(). >=20 > More subtly, table_scan_bitmap_next_block() used to return false if > there were no more visible tuples on the page or if the block that was > requested was not valid. With these changes, > table_scan_bitmap_next_block() will only return false when the bitmap > has been exhausted and the scan can end. In order to use the streaming > read API, the user must be able to request the blocks it needs without > requiring synchronous feedback per block. Thus, this table AM function > must change its meaning. >=20 > I think the way the patches are split up could be improved. I will > think more about this. There are also probably a few mistakes with > which comments are updated in which patches in the set. I look forward to the next version of the patch set. Thanks again for = working on this. =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company