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 1oCRHA-00014C-A7 for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Jul 2022 19:47:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oCRH9-0002fA-1G for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Jul 2022 19:46:59 +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 1oCRH8-0002Xc-5p for pgsql-hackers@lists.postgresql.org; Fri, 15 Jul 2022 19:46:58 +0000 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oCRH5-0007Hm-1l for pgsql-hackers@lists.postgresql.org; Fri, 15 Jul 2022 19:46:57 +0000 Received: by mail-lj1-x22d.google.com with SMTP id q7so6762220lji.12 for ; Fri, 15 Jul 2022 12:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=PJekueJdeRkXhQXHCxYdJhmuhO0lg0wE5/eYMFyotOk=; b=aG+dxMZ7bJY9eIlVX2Yb/EiBrbxcDMgqvVL96T5dTYdXLtL6ehcUlz4mbDhC6nXkwI Mis6CfPlYFjzxN83PBK/f96shtu1CFdw+0o0lW/WnhGOMqxJR1v5B/3pdtU7FBGjB7Q1 S9lD2xBThBm/llQ5weMK5z2ij0REEm+YuzpYqcwK0TU+FWOfGUbjSvtNyy5g9Tmhai/G K3H/BCVHJv0EsXTZTN50txxsK0ctVau4Opa9K9SGsVAUCG/789s9oXt/ue5g7uEJjOtf nEPnYFev1NH4AOylfEcY7Zfvf7gjxoAJknoADWnPAMrMFo80Qtnxj/hUunAYQCE7scXq 3KUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=PJekueJdeRkXhQXHCxYdJhmuhO0lg0wE5/eYMFyotOk=; b=KO1wzBjsf7Uf7Y9O3wAAEqU/vdxHnGYQs/9STcZeZ6MZGessX4iGrceVW6OzgB+HYz yaa5uPmy+IGFyGFdrPxlh0nAyHoU0wTvNN3yK7qAeaaUPMFjxA/blTpLsZDQR7ef6wCr sTaSdLY4tbRCf8vo05Q0e2hRmLuIEGI48IEoFjrJ2kCJ/RFG6LJg+pzwgcGGqTBnynip NfS8UQqsgR79i2o0kOUZCTtVNRvAWf4UjcYQoLKo4faYn3ItLanf4rUhEQAU+DegQITa Bz35mv36Yp1E1STQHSxmfuUgf7L53SbYuzaNvQ5hYvyfyTgh8M0hJIIsmG7PKOg0V6Yz 2VCw== X-Gm-Message-State: AJIora+ZTbC+3kxVij/4OOXklI7c79EcCkDqaqOk/OYDfBzb1LLSx+kQ 1A/Cy9KFlImWuNwgVqJIaGOmVA6Vel81qBPmpkT1ppihHfBJzwrYKtkdjrPHt0rwy4bm2evjy1H SNBI4RfksCjScdwk6F33XYHYZXYrJ0V0ftretfGX7Nh9SJl+IT6v+fXU9Y/JFhb0D+lh33t4Hjk GNLedXfGjvgjedBApU4jHqRSc0eDelWBmrqOPzwWPpxeVVLbcbnNJe X-Google-Smtp-Source: AGRyM1uRmjQypQaPInbXhLFPHWi3IilPm4/Y1lDmA4CyFlR1JHDY+E8R91tlAxYSvHlwSATklOWzGg== X-Received: by 2002:a2e:bea7:0:b0:25d:5eb6:7390 with SMTP id a39-20020a2ebea7000000b0025d5eb67390mr7337150ljr.269.1657914413253; Fri, 15 Jul 2022 12:46:53 -0700 (PDT) Received: from [10.137.0.17] (84-217-81-189.customers.ownit.se. [84.217.81.189]) by smtp.gmail.com with ESMTPSA id z5-20020a19f705000000b0048646c0af5csm1043113lfe.263.2022.07.15.12.46.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Jul 2022 12:46:52 -0700 (PDT) Message-ID: Date: Fri, 15 Jul 2022 21:46:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: POC: GROUP BY optimization Content-Language: en-US To: David Rowley Cc: Zhihong Yu , "Andrey V. Lepikhov" , Teodor Sigaev , Tomas Vondra , PostgreSQL Developers References: <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> <9408e450-60c6-6fbc-d5c4-467bb0abfe67@postgrespro.ru> <44472925-f6c6-e8de-6f72-0451458532c4@enterprisedb.com> <7a80a207-5e8e-b80c-476c-2d290b0526e9@enterprisedb.com> <65941e87-86c1-c09c-8ad5-8e102aebe8ee@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/15/22 07:18, David Rowley wrote: > On Thu, 31 Mar 2022 at 12:19, Tomas Vondra > wrote: >> Pushed, after going through the patch once more, running check-world >> under valgrind, and updating the commit message. > > I'm still working in this area and I noticed that db0d67db2 updated > some regression tests in partition_aggregate.out without any care as > to what the test was testing. > > The comment above the test reads: > > -- Without ORDER BY clause, to test Gather at top-most path > > and you've changed the expected plan from being a parallel plan with a > Gather to being a serial plan. So it looks like the test might have > become useless. > I agree this is a mistake in db0d67db2 that makes the test useless. > I see that the original plan appears to come back with some > adjustments to parallel_setup_cost and parallel_tuple_cost. It seems a > bit strange to me that the changes with this patch would cause a > change of plan for this. There is only 1 GROUP BY column in the query > in question. There's no rearrangement to do with a single column GROUP > BY. > It might seem a bit strange, but the patch tweaked the costing a bit, so it's not entirely unexpected. I'd bet the plan cost changed just a teeny bit, but enough to change the cheapest plan. The costing changed for all group counts, including a single group. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company