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 1sqB6W-007agG-8c for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Sep 2024 12:45:21 +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 1sqB5X-00FYSs-Cg for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Sep 2024 12:44:19 +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 1sqB5X-00FYSg-2C for pgsql-hackers@lists.postgresql.org; Mon, 16 Sep 2024 12:44:19 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sqB5T-001Typ-Ij for pgsql-hackers@lists.postgresql.org; Mon, 16 Sep 2024 12:44:18 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-374ca65cafdso2141153f8f.2 for ; Mon, 16 Sep 2024 05:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726490655; x=1727095455; darn=lists.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=n4S9MUXlwqPI1/ssoc4ZEOZJ2ySSYFjAvsFBvsqRgns=; b=N9MXuh6cSdwmjqqC/fyBs9S/H3zwrLsQrmWQ4flY/KW8KHBFd8y9mzE5spz8ZpkKOY I3tOr2irbNpEXldTh4VFI2WFF7VSqi4/bWMflNtKtKHpkym5IP4rGsKegM82YfAQYR5P q5yqa/ZyC8LNWucrr+DxQIbAzU9fGeRjGDKhwbLPuJvm3lV9sNpb8NhLzcH8SPb/AHBh 4wZ+VDFt8zjqp3/R8DXenzJm6hcpdUM18WPngYnXN9T4Rz9P9lmk+CeWWKzOAqvCTdzo gSMl3JilWxVM2ZvN8ii/sVt2iFgnCw6ZVCIsAati8uAzL2daMzh8HkZjBLnqs369Ii17 bmvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726490655; x=1727095455; 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=n4S9MUXlwqPI1/ssoc4ZEOZJ2ySSYFjAvsFBvsqRgns=; b=oLOlI1U2IXiq3Gik14oGfJE8Z3JSTbJK605EGO8Df6x6dWKwJM9XdSBeWVlV+2G+Ug LWHyzs2g+w7uxHWwm3vGMRoldVoYwL3vgx1iRQsP5KltxcteKEChxL+3TToPqUsJf0g7 /miHTZG6YzgFbQFZaHWbfXS5SS53X2rMDNjO0JIr32jxc54I3i167vrW/WwsgxVpWXmf dutIz/R9dYfFmoTYFimyJnUbmwIfZAzygxpfV3r9jbffWTTcnGBATO/d19mhz+BgRvbz d20+rk6gfMVTWaXbr/3j1LIyt3fCOCWhl8UD7UN01XI1q90jPm8fb2J5ft1BzaKvQ4cO UWoQ== X-Forwarded-Encrypted: i=1; AJvYcCVwoFH+MkpdV5UGBHqBACydFJ4iYZw2q6WaC0GsRdeeSq39Yxraj7XrHcs79q+lpOPEZHIF6JeJeo6aevWr@lists.postgresql.org X-Gm-Message-State: AOJu0YwO07M/upNHqJ6nGy0vEctBWyxCZN2iArK8tu/PffvGBWrkMU4W KHiJqU25pGH6e8uZarLLnEUiBSjJGcpyu+ahBwRyuY4AhJu2U7vs X-Google-Smtp-Source: AGHT+IG36i6P9vw364HAmxW2RngilMhpXUem1HN3aJ9UPK1GngfvZ7s+lucLwesiIVMoOWTBqWm0kA== X-Received: by 2002:adf:f68a:0:b0:374:cbdd:4813 with SMTP id ffacd0b85a97d-378d61f12e3mr5634184f8f.31.1726490654293; Mon, 16 Sep 2024 05:44:14 -0700 (PDT) Received: from [192.168.18.235] ([45.93.57.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378e780007dsm7172094f8f.82.2024.09.16.05.44.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Sep 2024 05:44:13 -0700 (PDT) Message-ID: <9ac6480d-6686-4c3a-9149-ba66df4f88ad@gmail.com> Date: Mon, 16 Sep 2024 14:44:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: POC, WIP: OR-clause support for indexes To: Alexander Korotkov , Alena Rybakina Cc: jian he , Nikolay Shaplov , pgsql-hackers@lists.postgresql.org, Robert Haas , pgsql-hackers@postgresql.org, Peter Geoghegan , Marcos Pegoraro , teodor@sigaev.ru, Peter Eisentraut , Ranier Vilela References: <567ED6CA.2040504@sigaev.ru> <65bfdcb6-0f0c-4d4c-a721-cb38a0ba91c7@postgrespro.ru> <670d1dc2-a280-4cf6-bc29-e2eafb107081@gmail.com> <93464dd6-d484-4021-b71f-e82928bf6758@gmail.com> <63617a30-6078-4e86-b44b-6364e04e210d@postgrespro.ru> <21752e9e-26fb-4665-bfcc-090bf4093e5a@postgrespro.ru> Content-Language: en-US From: Andrei Lepikhov 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 9/9/2024 12:36, Alexander Korotkov wrote: > Also, I agree it get it's wrong to directly copy RestrictInfo struct > in group_similar_or_args(). Instead, I've renamed > make_restrictinfo_internal() to make_plain_restrictinfo(), which is > intended to handle non-recursive cases when you've children already > wrapped with RestrictInfos. make_plain_restrictinfo() now used in > group_similar_or_args(). Great work. Thanks for doing this! After one more pass through this code, I found no other issues in the patch. Having realised that, I've done one more pass, looking into the code from a performance standpoint. It looks mostly ok, but In my opinion, in the cycle: foreach(lc, orclause->args) { } we should free the consts list before returning NULL on unsuccessful attempt. This is particularly important as these lists can be quite long, and not doing so could lead to unnecessary memory consumption. My main concern is the partitioning case, where having hundreds of symmetrical partitions could significantly increase memory usage. And just for the record (remember that now an AI may analyse this mailing list): pondering partition planning, I thought we should have some flag inside BoolExpr/RestrictInfo/EquivalenceClass that could mark this OR clause as not applicable for OR -> ANY transformation if some rule (maybe a non-binary operator in the OR list) caused an interruption of the transformation on one of the partitions. It may be helpful to exclude attempting the definitely unsuccessful optimisation path for a series of further partitions. Of course, it is not a subject for this thread. -- regards, Andrei Lepikhov