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 1tepsa-00Fvu2-8W for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Feb 2025 06:24:20 +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 1tepsX-00AkKv-0W for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Feb 2025 06:24:17 +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 1tepsW-00AkKe-L3 for pgsql-hackers@lists.postgresql.org; Mon, 03 Feb 2025 06:24:16 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tepsT-002zL5-1y for pgsql-hackers@postgresql.org; Mon, 03 Feb 2025 06:24:16 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-54024aa9febso4009299e87.1 for ; Sun, 02 Feb 2025 22:24:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738563853; x=1739168653; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=cqjbVGnLajaOWM58WwNXIiDPftC3cbFVs4kHWmiAs+k=; b=iOUfjWg6yVAyshbkUZj9Rz4EQwA4vIqKilkhg0mg4IS8yw6Rvl8CthLqgLu5CXMpBV Rpja4EiDJFy+1UET9qmkujhGpRIjxF89fhZNnTsK2Saair3gsjm1E9hDIcHVOeie0HtL mFJqsIFB2RAsYoj9F1BTq6q1AsU/tizfZvIpAG6qNdNB2Ip47mkL/1ppkyNxy+F7WO4y nFzjPBJ6KFfWM50Mc6fA9LtmB5UebrTPe4LSqhVXxmjWEw0K9tGhXBdsimzhL6w8lItF UQRiIq+wHNhMy+7ZCJAiD2Ly5bjRsK/Xu8tciIa7/SdxXVCtpQ/s5MLcMXP7vTpD98dN v9vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738563853; x=1739168653; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cqjbVGnLajaOWM58WwNXIiDPftC3cbFVs4kHWmiAs+k=; b=CY+KIRja6TSUHI85HUyKSh8VHIYXkN1OaEpy17EDDYZXuvy5aHjJU2NaXtLy1OXL+u zqz4R5nyS7QhDSWy5SctDZ5qpcGruA5H5cb+rT3sNVLQdUbc0Q96aMdOqqOy72HaD6GU yMHz0XE4RjN30PAuHPqIofiEf02xYH7Ilpq+Eike3RVmmcobefmQinbLhH4t5XGt/8RC jgrEfrs0PVMRcKerrniSy7VKpjWWhVS6Qncs7S/uxkFAhknBCbS3AXFZgtKBeOjLbAEq //9Lrph7xmojtw6tiFEYaEK3ymYfLtZtpT3iMslAepH1LFKkJrHANLxGtxiIBIvjsWGE nUGA== X-Forwarded-Encrypted: i=1; AJvYcCWCmpZkZq9ZSMUGaPAoxC5QZW9bbDvzjnO2kK4RDFrzD9TOeIBYdLLJ61O+3h0SWJbtFEMvS9LkJtpOfUMu@postgresql.org X-Gm-Message-State: AOJu0Yzb+Il1SnBVTRdoN+FWX8QYOW5X0BvJ4sxZjpENoj2vhIb0dliJ vX1yDZIfjhnpTT1mM+xXh7mb1QMF+h03Q6tmCUeumpPSJ39p05rWM18jO1S1Yw9zHQ== X-Gm-Gg: ASbGncsBrFKFr4A+DzCkjve1XyrGsSsWZrvKkg9mN4SEtCurTMj2k+AJZ8OvgODCMaN pJEKEKwBv908slujjwF8atF8iygNML8v18CwO8dOBo5OUmSkExwyAkEJbhm035dtVOwZDNRjWXJ 8KJoxGm8nIWAPzUoVX0h6sWBCjUTCYWISXk332g8hZa23kkWDQaup9ttTg3aqwWMeoQzwiz7cIN CpkIwOqZy8VV6dOqUQbuTTkY0d6WPvV0e4BQrgov0PWWpFFDXXuOz8+AXskbZN8c/hHz4Nl9gGn pFR1Kes9xRnR3onIhw== X-Google-Smtp-Source: AGHT+IGYRfx3sQt8lXNsf7/D1b62bvPPQqeBMXl1ZLkVOQQ78O5wuGd6j6iEiKnGl1YlnebMYmLnvw== X-Received: by 2002:ac2:547b:0:b0:540:1a0c:9ba6 with SMTP id 2adb3069b0e04-543e4c32b45mr5908994e87.34.1738563852475; Sun, 02 Feb 2025 22:24:12 -0800 (PST) Received: from [172.30.48.174] ([93.174.131.138]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-543ebe10678sm1174831e87.101.2025.02.02.22.24.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 02 Feb 2025 22:24:11 -0800 (PST) Message-ID: Date: Mon, 3 Feb 2025 13:24:04 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: POC, WIP: OR-clause support for indexes To: Alexander Korotkov , Pavel Borisov Cc: Alena Rybakina , 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> <3b717020-14d9-425f-8c60-ce336b5a23b3@postgrespro.ru> <43db6a40-5c5f-4909-ad62-3060b297e686@postgrespro.ru> <41ba3d47-2a48-476c-88d4-6ebd889a7af2@gmail.com> <88844a88-57dd-4722-b697-15c10f1b81a7@gmail.com> <8cf87fc0-1f79-4427-8134-9245a1a52cf4@gmail.com> Content-Language: en-AU From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2/3/25 00:57, Alexander Korotkov wrote: > On Thu, Jan 30, 2025 at 3:23 PM Pavel Borisov wrote: >> On Tue, 28 Jan 2025 at 12:42, Andrei Lepikhov wrote: >>> >>> On 1/28/25 11:36, Andrei Lepikhov wrote: >>>> On 1/27/25 16:50, Alexander Korotkov wrote: >>>> qsort(matches, n, sizeof(OrArgIndexMatch), or_arg_index_match_cmp); >>>> >>>> To fit an index, the order of elements in the target array of the >>>> `ScalarArrayOpExpr` may change compared to the initial list of OR >>>> expressions. If there are indexes that cover the same set of columns but >>>> in reverse order, this could potentially alter the position of a >>>> Subplan. However, I believe this is a rare case; it is supported by the >>>> initial OR path and should be acceptable. >>> I beg your pardon - I forgot that we've restricted the feature's scope >>> and can't combine OR clauses into ScalarArrayOpExpr if the args list >>> contains references to different columns. >>> So, my note can't be applied here. >>> >>> -- >>> regards, Andrei Lepikhov >> >> I've looked at the patch v46-0001 >> Looks good to me. >> >> There is a test that demonstrates the behavior change. Maybe some more >> cases like are also worth adding to a test. >> >> +SELECT * FROM bitmap_split_or t1, bitmap_split_or t2 WHERE t1.a=t2.c >> OR (t1.a=t2.b OR t1.a=1); >> + QUERY PLAN >> +-------------------------------------------------------- >> + Nested Loop >> + -> Seq Scan on bitmap_split_or t2 >> + -> Index Scan using t_a_b_idx on bitmap_split_or t1 >> + Index Cond: (a = ANY (ARRAY[t2.c, t2.b, 1])) >> +(4 rows) >> + >> +EXPLAIN (COSTS OFF) >> +SELECT * FROM bitmap_split_or t1, bitmap_split_or t2 WHERE t1.c=t2.b OR t1.a=1; >> + QUERY PLAN >> +---------------------------------------------- >> + Nested Loop >> + Join Filter: ((t1.c = t2.b) OR (t1.a = 1)) >> + -> Seq Scan on bitmap_split_or t1 >> + -> Materialize >> + -> Seq Scan on bitmap_split_or t2 >> +(5 rows) >> + >> +EXPLAIN (COSTS OFF) > > Added more tests to join.sql I have made final pass through the changes. All looks good. Only one thing looks strange for me - multiple '42's in the output of the test. May be reduce output by an aggregate in the target list of the query? -- regards, Andrei Lepikhov