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 1rcHMC-001wUN-Hi for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Feb 2024 04:03:48 +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 1rcHMA-000msf-A4 for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Feb 2024 04:03:46 +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 1rcHM9-000msW-Ve for pgsql-hackers@lists.postgresql.org; Tue, 20 Feb 2024 04:03:45 +0000 Received: from mail-ua1-x929.google.com ([2607:f8b0:4864:20::929]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rcHM6-007coJ-VH for pgsql-hackers@postgresql.org; Tue, 20 Feb 2024 04:03:44 +0000 Received: by mail-ua1-x929.google.com with SMTP id a1e0cc1a2514c-7d625a3ace6so3385118241.0 for ; Mon, 19 Feb 2024 20:03:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708401822; x=1709006622; darn=postgresql.org; 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=rQRP5Zbw1t2culm0GdQNmwPrg+p51rvyo5cDYQzNC3c=; b=jPb1kvpEd2Mm55EdN/8Ic8yFlt1h4G060me6ivlo1NmToT1ccG3Un6v2GMWBReN35Q pUSUcnHO/WBjYuRovQPJhYhfH/ZbKskdXN4KXsa5WP9q9vSz1q2rQmBDG//1FE72FFTy qItxrRXow7w3+LsierRT8F3Byaj97t4cQOqFwZszvSSAejd8v2oHlPh19VY0slhDPvVj SIArltmEFrF1tlkZe/XMTSCC6EOZcxDBNbuhZYqAQNpm4DEO7VgeUNFU6LdBKEe7ym92 dQrcqZoYugxNHOFD7l0cp+z2y/N8p1I7qwvo4w+suqo0NXzKyeldM5plkumpFacDXMrj yMKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708401822; x=1709006622; 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=rQRP5Zbw1t2culm0GdQNmwPrg+p51rvyo5cDYQzNC3c=; b=bXaWe1YYaHlbpTOAHsR1RnIrhY+C+XvTsCoielZe3fZtl2NLtu5hFyUI2e6f0v+B8n +Mf3FLZgQ6JEg3yvqnzu1cMi49nhvQ8WYI1bnwoAKR0Yf7DuqmrtnDMhytaaSg0yDEye 3o2XfBsbjx+ekomNiIQM30zgmMSJsDy+pnUr6vQMmyAgL54z5qWn6zDityZ9SQD6uojx f+HG2xarTTJNYxDhS+iwaoz3IcPhaNNNMooTi4kkCAfWdykMSAw234VKMnUUgsGxikFR NTFaC09UwV+cbLn/yfPihVHR0QMa8D/SHtoS11QGK5VZ9YcVkJRga/fGkkOdzH6qpzKm BwWQ== X-Forwarded-Encrypted: i=1; AJvYcCWh+ol41mnX5ZP8BzCTnw2ytWjz6msyvrBdqgccN+4MDcdUQgWCHY2/lu6r8ZfFqidlT8AznUPgx8AvVt3BqjvQI6/Sir5do5dMe2NC X-Gm-Message-State: AOJu0YzDzF0bdLjoHR8CQZ0IB46CchqTi6q/L8ZhAAzoA8FdYok+5EY7 s8a1yKe/mjIM1uuxxjmKYpc7ihcgOT3Pn05TZ43+I9eOECOAbchTNRNdbXIQvAQiRhnw62YSTZE HtRRzI5N4lephM6E5ddkuBPFEs8w= X-Google-Smtp-Source: AGHT+IFih3Ms35dPO37CJ9B3eKOT9yKcuPEqLhudlZYPxioh+a1BWsvMnG+BkaAd7YzMsPGZi8ypUUfLo93frrpKAtw= X-Received: by 2002:a05:6102:2923:b0:470:66da:b98 with SMTP id cz35-20020a056102292300b0047066da0b98mr2454458vsb.0.1708401822017; Mon, 19 Feb 2024 20:03:42 -0800 (PST) MIME-Version: 1.0 References: <567ED6CA.2040504@sigaev.ru> <32d23d97-d07f-4d44-9933-ba3295fb3ed8@postgrespro.ru> <7e11e27b-7ab9-4d59-af0a-a921861a9206@postgrespro.ru> <13ad923a-33df-4b44-9e00-c9323cd4c37d@postgrespro.ru> <1cf6b382-6e27-4268-9f2a-54ada66eb2eb@postgrespro.ru> <5f119769-ab11-4807-abcc-71d5dd914ea0@postgrespro.ru> In-Reply-To: From: jian he Date: Tue, 20 Feb 2024 12:03:31 +0800 Message-ID: Subject: Re: POC, WIP: OR-clause support for indexes To: Andrei Lepikhov Cc: Alena Rybakina , Alexander Korotkov , Robert Haas , pgsql-hackers@postgresql.org, Peter Geoghegan , "Finnerty, Jim" , Marcos Pegoraro , teodor@sigaev.ru, Ranier Vilela , Tomas Vondra , Peter Eisentraut 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 Mon, Feb 19, 2024 at 4:35=E2=80=AFPM Andrei Lepikhov wrote: > > In attachment - v17 for both patches. As I see it, the only general > explanation of the idea is not addressed. I'm not sure how deeply we > should explain it. > On Tue, Nov 28, 2023 at 5:04=E2=80=AFAM Robert Haas wrote: > > On Mon, Nov 27, 2023 at 3:02=E2=80=AFAM Andrei Lepikhov > wrote: > > On 25/11/2023 08:23, Alexander Korotkov wrote: > > > I think patch certainly gets better in this aspect. One thing I can'= t > > > understand is why do we use home-grown code for resolving > > > hash-collisions. You can just define custom hash and match functions > > > in HASHCTL. Even if we need to avoid repeated JumbleExpr calls, we > > > still can save pre-calculated hash value into hash entry and use > > > custom hash and match. This doesn't imply us to write our own > > > collision-resolving code. > > > > Thanks, it was an insightful suggestion. > > I implemented it, and the code has become shorter (see attachment). > > Neither the code comments nor the commit message really explain the > design idea here. That's unfortunate, principally because it makes > review difficult. > > I'm very skeptical about the idea of using JumbleExpr for any part of > this. It seems fairly expensive, and it might produce false matches. > If expensive is OK, then why not just use equal()? If it's not, then > this probably isn't really OK either. But in any case there should be > comments explaining why this strategy was chosen. The above message (https://postgr.es/m/CA%2BTgmoZCgP6FrBQEusn4yaWm02XU8OPeoEMk91q7PRBgwaAkFw%= 40mail.gmail.com) seems still not answered. How can we evaluate whether JumbleExpr is expensive or not? I used this naive script to test, but didn't find a big difference when enable_or_transformation is ON or OFF. ` create table test_1_100 as (select (random()*1000)::int x, (random()*1000) y from generate_series(1,1_000_000) i); explain(costs off, analyze) select * from test where x =3D 1 or x + 2=3D 3 or x + 3=3D 4 or x + 4=3D 5 or x + 5=3D 6 or x + 6=3D 7 or x + 7=3D 8 or x + 8=3D 9 or x + 9=3D10 or x + 10=3D 11 or x + 11=3D 12 or x + 12=3D 13 or x + 13=3D 14 or x + 14=3D 15 or x + 15=3D 16 or x + 16=3D 17 or x + 17=3D 18 or x + 18=3D19 or x + 19=3D 20 or x + 20=3D 21 or x + 21=3D 22 or x + 22=3D 23 or x + 23=3D 24 or x + 24=3D 25 or x + 25=3D 26 or x + 26=3D 27 or x + 27=3D28 or x + 28=3D 29 or x + 29=3D 30 or x + 30=3D 31 \watch i=3D0.1 c=3D10 ` `leftop operator rightop` the operator can also be volatile. Do we need to check (op_volatile(opno) =3D=3D PROVOLATILE_VOLATILE) within transformBoolExprOr?