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 1qP1YH-009kze-3B for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Jul 2023 14:01:13 +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 1qP1YF-00ALBx-HG for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Jul 2023 14:01:11 +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.94.2) (envelope-from ) id 1qP1YF-00ALBn-3h for pgsql-hackers@lists.postgresql.org; Thu, 27 Jul 2023 14:01:11 +0000 Received: from mail-vk1-xa34.google.com ([2607:f8b0:4864:20::a34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qP1YA-001rqA-MZ for pgsql-hackers@lists.postgresql.org; Thu, 27 Jul 2023 14:01:09 +0000 Received: by mail-vk1-xa34.google.com with SMTP id 71dfb90a1353d-4866be648ffso180597e0c.2 for ; Thu, 27 Jul 2023 07:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20221208.gappssmtp.com; s=20221208; t=1690466465; x=1691071265; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hL1j7ZRBvPmyDGJ9NjlO2ZfPnVgzg+4KgsFCRWW7S98=; b=zuov3115odBkgfRSHu/qI7CWCAPLQLCXmqdLWqyt/Q/WtgPC/JEsFBxS4yKvqoWnQq wo3APxeusP5wRWme+s+5YwjLuGxeOvMXjlRAA3GkrDiiNmY9huayisVhCnIv6aY2oKkN Sezg0afb5y1BIU38PR+lmWdm3TO1r+18ehVq3eeJ+lU4i7GPnx341EYMdJBSpZ3xOCOZ LjScTtfqQXD/N0L6jLHXmKNJkK+t7sUlQmq/BmTWFDwWK7N5O/jWCmTuTlKSsUblN3hh JzSvNGntu6rtAIHeJ3+NgQK+c+R4FgCsVrrhAf3FBHFHCC3GGWVtYh16hlmbTN5MJowm t1Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690466465; x=1691071265; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hL1j7ZRBvPmyDGJ9NjlO2ZfPnVgzg+4KgsFCRWW7S98=; b=RP0pPpmuYEc0UeyyShOuchzNr8zfB6c0HLLH/HViHBcYUnadaxl0s758muIy/gn+go kFPcH/52rZDAs0aCYHAYt+jXC2ib+2jU8skU9uyw2YiTXquWSd9YX3EMiovPR7X0IEZ4 dj64+/PghQsB1FWG5MfXysT9TgySmj2v37YSAr+Ytql+NWXIlQSWFyrhzeltm46R2tfB NDU7XU4JzN9RYpT+WGdPzoRzE5H2DAA/cYxCgsLpCBG+nVd8KyfdP9npsFA9/mkqOSil mKA9oNHe0nn9LU52KXXkNhfKNTw3I9MqrcdgSy/zkRw+vDOTbiJ7QQYfuYiKmg8KX7m8 FGyA== X-Gm-Message-State: ABy/qLZUpCkcW4SMtdMEAukiDWgyDicLxFeRBwZ+P9RG0gzti75Zoq9I gndHZ9TcNK4KlZqMQdQy80XOdmKQv/4EUJA5Q7ub2g== X-Google-Smtp-Source: APBJJlEq2DZZqfo5kyyH+oaUjjnrAzcVVQZGJ+bAxpIxu7EDRqZ/gEdE8tX6yNRzwjJi6h88cnpa07/Sj4Z3+jb6F7c= X-Received: by 2002:a1f:438c:0:b0:486:4458:863 with SMTP id q134-20020a1f438c000000b0048644580863mr1496839vka.2.1690466457968; Thu, 27 Jul 2023 07:00:57 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Peter Geoghegan Date: Thu, 27 Jul 2023 10:00:31 -0400 Message-ID: Subject: Re: Optimizing nbtree ScalarArrayOp execution, allowing multi-column ordered scans, skip scan To: Matthias van de Meent Cc: PostgreSQL Hackers , Tom Lane , Tomas Vondra , Jeff Davis , benoit Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jul 27, 2023 at 7:59=E2=80=AFAM Matthias van de Meent wrote: > > Basically, the patch that added that feature had to revise the index > > AM API, in order to support a mode of operation where scans return > > groupings rather than tuples. Whereas this patch requires none of > > that. It makes affected index scans as similar as possible to > > conventional index scans. > > Hmm, yes. I see now where my confusion started. You called it out in > your first paragraph of the original mail, too, but that didn't help > me then: > > The wiki does not distinguish "Index Skip Scans" and "Loose Index > Scans", but these are not the same. A lot of people (myself included) were confused on this point for quite a while. To make matters even more confusing, one of the really compelling cases for the MDAM design is scans that feed into GroupAggregates -- preserving index sort order for naturally big index scans will tend to enable it. One of my examples from the start of this thread showed just that. (It just so happened that that example was faster because of all the "skipping" that nbtree *wasn't* doing with the patch.) > Yes, that's why I asked: The MDAM paper's examples seem to materialize > the full predicate up-front, which would require a product of all > indexed columns' quals in size, so that materialization has a good > chance to get really, really large. But if we're not doing that > materialization upfront, then there is no issue with resource > consumption (except CPU time, which can likely be improved with other > methods) I get why you asked. I might have asked the same question. As I said, the MDAM paper has *surprisingly* little to say about B-Tree executor stuff -- it's almost all just describing the preprocessing/transformation process. It seems as if optimizations like the one from my patch were considered too obvious to talk about and/or out of scope by the authors. Thinking about the MDAM paper like that was what made everything fall into place for me. Remember, "missing key predicates" isn't all that special. --=20 Peter Geoghegan