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 1tXyhb-000311-R5 for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Jan 2025 08:24:40 +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 1tXyhY-008tS4-Kp for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Jan 2025 08:24:37 +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 1tXyhY-008tQB-8Y for pgsql-hackers@lists.postgresql.org; Wed, 15 Jan 2025 08:24:36 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tXyhX-000VCW-1L for pgsql-hackers@lists.postgresql.org; Wed, 15 Jan 2025 08:24:35 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2163dc5155fso117533095ad.0 for ; Wed, 15 Jan 2025 00:24:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736929474; x=1737534274; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=zt0gKMmTy+qj0T/fq3swZJcwKH2n7aZMrWwh8YLELAg=; b=kmZgDbucLySjZpEFj0D3syYUY8y2fvzzGi6YM+/D8miaXBUwmDBeykMPaHqvfYL6Ew bWk9ykyXnUpJL+fc4EF9Wt643bvzifhgDLPx6IXTTSPCWUzghN8h2ntBl3vN2zdMs/Xa hHOVzXDZ42YurCovB0q5sH28Rd9ppDkcCD9/ccGF68E8FxNHDtdt2dBLYX6CLwAmZRV0 c5UtJ3X/GhxHiq0ND9AUiVGXykLXz2BOTu2+zw5NoLuq/qxQHVrsHqfTBQ6CbPE95myO TMNoyxpQwlb1jpoXW7ombYxZ3iMk7GWlycEzEeWMU3NqOy0lSF1IQq00hX0OiRCM/QHj cIJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736929474; x=1737534274; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zt0gKMmTy+qj0T/fq3swZJcwKH2n7aZMrWwh8YLELAg=; b=hTz7D6H3DxVDIqCcpUYxrn7Evyfpgi6q8ELD0pYEWjTfSbKwZoaNyFaDS9z3gk5v7b sr9Vk5Y0AqqLN/QQI7nVcW5kciYFTaOu3ygUDd655mP+lOncWd39OtFp6kACmnmy6E9i j6ffHGOtx+cg0JE+sEeutuUz4X42obiC1Zr+NIKn51nkg3H3Ojb+zQOtuEvT48/fhcC5 4cTC8ZPcx2kI3uhiymptM7znhXUx10+ZqJd7q7cTShc/GmtwvMzMHZlaBkJfJcXoAn/K JIPy0hXfiH9Ykr3z7aBOYV6o/ORHGdEm7oaftt0cnp1PpXusaZK9gg+CQWqgLxBP9Z3N oqDQ== X-Forwarded-Encrypted: i=1; AJvYcCU7mB0X4TJVRXETWGK0CWJSeHgieLoPnCIbHbjGroavwxGafsIO3zjf1WvAc8T1sA0FfRzXt3DyU95IAb0E@lists.postgresql.org X-Gm-Message-State: AOJu0YxLDtZECBXsgMcEAevQgdhg6//a4RPRG4GnbxRKolLA25EDro3z FXimisdLjowiWQkfDlaeKQC64/JDf27CfC/SbYbxU4tveP3fL5yk X-Gm-Gg: ASbGncsGSUpIf4ABmmFo2Nekx/V0qif6sfQL8u6WsOsiVBo1rWn9C/puUTnKIeOTmS1 QLDXf5KXR8oM6nqsctJzgPVR2kBD4P9P/gzu2tu8D/5xxCZW/HFU5l5T4osoSFUtQf08GOlOnlo TrNJqEViyvKBIM7kxl/IsxMZuC/ebQVJudUGW9fZPE2AqnU2XEPaz7ulKqo67FKq4HZXmK1Z/Ls qIUgD8QvxIyg+TeneWAdcLp1e3nxlbcJhDhi9hctxhHY0MkmRjftdgaEQAKE5wxWe+gCWh9Xbhy 9ref5A5OjSjHZa7TnugBRR0UehasCRp2 X-Google-Smtp-Source: AGHT+IGbFAOHJSs/ep18v5zfUSbzI/COTlkelYTgeAlVgavJ1XAv+P4gjCMen5XdkSs0GsFDKtpvJw== X-Received: by 2002:a05:6a20:a10f:b0:1e1:a829:bfb6 with SMTP id adf61e73a8af0-1e88cf7f5bdmr45501339637.3.1736929473748; Wed, 15 Jan 2025 00:24:33 -0800 (PST) Received: from [10.10.20.106] (node-y9i.pool-101-51.dynamic.totinternet.net. [101.51.173.118]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d40658a73sm8652591b3a.119.2025.01.15.00.24.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Jan 2025 00:24:33 -0800 (PST) Message-ID: <41ba3d47-2a48-476c-88d4-6ebd889a7af2@gmail.com> Date: Wed, 15 Jan 2025 15:24:27 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: POC, WIP: OR-clause support for indexes From: Andrei Lepikhov To: Alexander Korotkov , Alena Rybakina Cc: Ranier Vilela , Alexander Lakhin , jian he , Robert Haas , Nikolay Shaplov , pgsql-hackers@lists.postgresql.org, pgsql-hackers@postgresql.org, Peter Geoghegan , Marcos Pegoraro , teodor@sigaev.ru, Peter Eisentraut References: <567ED6CA.2040504@sigaev.ru> <0026f562-d403-4f97-b9dc-3fe3a279e8c9@postgrespro.ru> <37bf870a-22e0-4aba-b845-549482118f8d@gmail.com> <8174de69-9e1a-0827-0e81-ef97f56a5939@gmail.com> <3b717020-14d9-425f-8c60-ce336b5a23b3@postgrespro.ru> <43db6a40-5c5f-4909-ad62-3060b297e686@postgrespro.ru> Content-Language: en-AU In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/13/25 10:39, Andrei Lepikhov wrote: > On 1/13/25 01:39, Alexander Korotkov wrote: > It can be resolved with a single-line change (see attached). But I need > some time to ponder over the changing behaviour when a clause may match > an index and be in joinorclauses. In addition, let me raise a couple of issues: 1. As Robert has said before, it may interfere with some short-circuit optimisations like below: EXPLAIN (COSTS OFF) SELECT * FROM bitmap_split_or t1 WHERE t1.a=2 AND (t1.b=2 OR t1.b = ( SELECT sum(c1.reltuples) FROM pg_class c1, pg_class c2 WHERE c1.relpages=c2.relpages AND c1.relpages = t1.a)); Here, a user may avoid evaluating the subplan at all if t1.b=2 all the time when t1.a=2. OR->ANY may accidentally shift this behaviour. 2. The query: EXPLAIN (ANALYZE, COSTS OFF) SELECT * FROM bitmap_split_or t1 WHERE t1.a=2 OR t1.a = ( SELECT sum(c1.reltuples) FROM pg_class c1, pg_class c2 WHERE c1.relpages=c2.relpages AND c1.relpages = t1.a)::integer; causes SEGFAULT during index keys evaluation. I haven't dived into it yet, but it seems quite a typical misstep and is not difficult to fix. -- regards, Andrei Lepikhov