Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fYtBm-00084X-Gp for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Jun 2018 13:11:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fYtBk-0008K9-4d for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Jun 2018 13:11:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fYtBj-0008K2-UF for pgsql-hackers@lists.postgresql.org; Fri, 29 Jun 2018 13:11:47 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fYtBg-0005R6-IJ for pgsql-hackers@postgresql.org; Fri, 29 Jun 2018 13:11:47 +0000 Received: by mail-wm0-x243.google.com with SMTP id w137-v6so2165323wmw.1 for ; Fri, 29 Jun 2018 06:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=er8XU3wmWW7NjHSGd9IpwjtLjDqydRl7TMz8D9ltGVk=; b=APuD5R6Vlf8AKFlLGyZtqzm6r1LXPlCEalyhF1rPmexUp/szUFPejIHstKmbMHhABN HjeZyK+7GUT/S7dz3wBPj3JMP2BiNDVdVb5cSyZPmbAjVDFuwGJKZcOVkVG1lKM/av6Q 0X6ZmGqByQZRviz0Yt5e2/StbNOIHeQPXQF6kvZRowjuaZiUmMHObkcrI3zsnSNoTWsz EzoQDTttDw/+P5PmsfoSWTgj5EP1WKsNQ7ZEOtCYTbbQ4DruCKsMLONwh/8r7ank/O2M Al4GhPK2Ke5KahOrriOOB1uL6n+fKL/fMDVW2ZT9NcMATX7yYR3Xe7TM3rJ8fe5c2KFk 1yag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=er8XU3wmWW7NjHSGd9IpwjtLjDqydRl7TMz8D9ltGVk=; b=DYk+RoxoNL0VdnnLqoUY2cNlFULz64kQIiGY5WAfaAloaVlVrDcYEQKvffVO477P4A GYGIzz2gRBwFKcr5lsJKf7Z1Ad6wpNQP1MUU21Pgy1aOrzf78bMOsAvSHuk8sMnSSSMt Ndqy1UgxOX/EuPKiVspF2PX1a/uqNmH1R/gdE7SRScC3xGsrOOOD02vrEnHpEY6K/26X IQT73bQDoe1bAqYr+RNmNP3zJTNx9vtGmwSjxZ2N7U+NOqNpbiBUwHhpqhKfs4OPjQ1T Y2phTVkvC8IXdM6wq3zG5mB94oJGhL3DsLNyL9K4Ql9YQ01W5UD9VOb+KIjQxDPnPB9c S4WQ== X-Gm-Message-State: APt69E0v0BjywNsTrMbodUJDJPnXiMF0jJrrIeuJtKhtCwAxh4YWCEPQ D6bBDpm0ltLYu7pkxg9XZ36Rs8G8J34PoODrtgrDTorkjpCAVs/AJvzn/Mv8Yc6AMe64vv7f6CH cH/Fn2p5Kthz80u7bX79M1Yyl7KAWrhmCPuBHCfDkSFbXBcF43a9CrCPyutncwEXeE2QBVx72jf 0j0Ow/1By3 X-Google-Smtp-Source: AAOMgpfu1Lth5z2qp4RwHuPGaQjiHszGDZ+hh1/j1mC4hFyIYdkCEkNRfawAiE/2Be3eDQwGnY8S2Q== X-Received: by 2002:a1c:2d54:: with SMTP id t81-v6mr1884323wmt.31.1530277903553; Fri, 29 Jun 2018 06:11:43 -0700 (PDT) Received: from [10.137.2.21] (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id u16-v6sm7352243wrp.44.2018.06.29.06.11.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 06:11:41 -0700 (PDT) Subject: Re: POC: GROUP BY optimization To: Teodor Sigaev , Pgsql Hackers References: <7c79e6a5-8597-74e8-0671-1c39d124c9d6@sigaev.ru> <97d148b7-f3e7-1c39-07fd-74cbc66f6ec9@sigaev.ru> <6d1e0cdb-dde3-f62a-43e2-e90bbd9b0f42@2ndquadrant.com> <7edddb4f-9ddd-561d-2bde-47340f91d2a0@2ndquadrant.com> <2cb99655-7ae7-ec8d-2c74-3fea58987104@sigaev.ru> <6dddcce6-0d91-1868-794a-4d61dc5516f0@2ndquadrant.com> <523d1f60-c60c-5c8c-8cc5-c6c078970da6@2ndquadrant.com> <24c773b8-3a9a-8fe9-610d-01145758931b@sigaev.ru> <623f5e50-eeb2-1279-d30b-dc43611fb063@2ndquadrant.com> From: Tomas Vondra Message-ID: <1913e082-0d8d-5eb8-c8ca-053af828076a@2ndquadrant.com> Date: Fri, 29 Jun 2018 15:11:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=koi8-r; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 06/28/2018 06:52 PM, Teodor Sigaev wrote: >> I'm afraid that's a misunderstanding - my objections did not really go >> away. I'm just saying my claim that we're not messing with order of >> grouping keys is not entirely accurate, because we do that in one >> particular case. >> >> I still think we need to be careful when introducing new optimizations >> in this area - reordering the grouping keys by ndistinct, ORDER BY or >> whatever. In particular I don't think we should commit these patches >> that may quite easily cause regressions, and then hope some hypothetical >> future patch fixes the costing. Those objections still stand. > > Pls, have a look at https://commitfest.postgresql.org/18/1706/ > I tried to attack the cost_sort() issues and hope on that basis we can > solve problems with 0002 patch and improve incremental sort patch. > OK, will do. Thanks for working on this! regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services