Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nV6hY-0006gb-BM for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Mar 2022 07:07:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nV6hW-0003GH-83 for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Mar 2022 07:07:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nV6hV-0003G5-Sw for pgsql-hackers@lists.postgresql.org; Fri, 18 Mar 2022 07:07:05 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nV6hS-0000OD-1G for pgsql-hackers@lists.postgresql.org; Fri, 18 Mar 2022 07:07:04 +0000 Received: from [192.168.28.53] (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 7322021C964E; Fri, 18 Mar 2022 10:06:58 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1647587218; bh=AWYEtnd/g0FlYftXWQ8ZX1l1Z/GTftodC2mE4HeIK8g=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=Wz6ify/i/9ymldHo18wMdW1sEz2Y6YOwowZdNLXmjCMLNLGSTfriBgrcx4CDxLuiS X2PH77cH3vWhQ5NX9ugceDUDvSnTpTMgnwFpGeZ1RnCBT4+lfGOelQ9x49g7XD/QtS cD2D8eQYlydgTsI0JrpvtQ8v7vSurBdiwqxQi9qQ= Message-ID: <9408e450-60c6-6fbc-d5c4-467bb0abfe67@postgrespro.ru> Date: Fri, 18 Mar 2022 12:06:57 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: POC: GROUP BY optimization Content-Language: en-US To: Tomas Vondra , Teodor Sigaev Cc: Tomas Vondra , PostgreSQL Developers References: <20201026104040.6bigvej6f55vjvgp@localhost> <20201027201509.jfv6sfhrmxhdwlvk@development> <20201029145025.tn3tekboot37nkbf@localhost> <22c44f98-bfa8-8630-62b5-5155e11eb284@enterprisedb.com> <006667af-fc50-0627-4be7-5d9cf665219f@enterprisedb.com> <4ee5b15c-1ce0-59c7-8d4a-a1fd68ee0d12@postgrespro.ru> <721b3ff9-f214-f5d4-86c7-bae515bbec18@enterprisedb.com> <7bea462e-8c3e-0f8c-c7d5-f4daa12f3baf@postgrespro.ru> <9af89543-3d17-4c98-59de-1daa5bceeb06@enterprisedb.com> From: "Andrey V. Lepikhov" Organization: Postgres Professional In-Reply-To: <9af89543-3d17-4c98-59de-1daa5bceeb06@enterprisedb.com> 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 3/15/22 13:26, Tomas Vondra wrote: > Thanks for the rebase. The two proposed changes (tweaked costing and > simplified fake_var handling) seem fine to me. I think the last thing > that needs to be done is cleanup of the debug GUCs, which I added to > allow easier experimentation with the patch. Thanks, I'm waiting for the last step. > > I probably won't remove the GUCs entirely, though. I plan to add a > single GUC that would enable/disable this optimization. I'm not a huge > fan of adding more and more GUCs, but in this case it's probably the > right thing to do given the complexity of estimating cost with > correlated columns etc. Agree. Because it is a kind of automation we should allow user to switch it off in the case of problems or manual tuning. Also, I looked through this patch. It has some minor problems: 1. Multiple typos in the patch comment. 2. The term 'cardinality of a key' - may be replace with 'number of duplicates'? -- regards, Andrey Lepikhov Postgres Professional