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 1fQweE-0008Kp-AF for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Jun 2018 15:16:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fQweC-0007gB-Dj for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Jun 2018 15:16:20 +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 1fQweC-0007g1-6q for pgsql-hackers@lists.postgresql.org; Thu, 07 Jun 2018 15:16:20 +0000 Received: from hook.sigaev.ru ([93.180.27.50]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQwe7-0002Ad-Qp for pgsql-hackers@postgresql.org; Thu, 07 Jun 2018 15:16:19 +0000 Received: from xor.sai.msu.ru (unknown [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: teodor) by hook.sigaev.ru (Postfix) with ESMTPSA id 378F0B19192; Thu, 7 Jun 2018 18:16:14 +0300 (MSK) Subject: Re: POC: GROUP BY optimization To: Tomas Vondra , Claudio Freire Cc: PostgreSQL-Dev 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> <4a76e22a-045f-a083-1bc2-84ee90fdb662@2ndquadrant.com> <736c5ece-7ac4-241b-4a11-52797691238f@sigaev.ru> <8260d372-8826-31ef-68e6-a7ff8a7265d9@2ndquadrant.com> From: Teodor Sigaev Message-ID: Date: Thu, 7 Jun 2018 18:16:13 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.3 MIME-Version: 1.0 In-Reply-To: <8260d372-8826-31ef-68e6-a7ff8a7265d9@2ndquadrant.com> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >> Again agree. If we have fixed order of columns (ORDER BY) then we should not >> try to reorder it. Current patch follows that if I didn't a mistake. >> > > This part seems to be more a misunderstanding between me and Claudio. I believe > Claudio was referring to the column order in a GROUP BY, not ORDER BY. In which > case we don't add any Sort, of course. I hope so > > I'm still opposed to adding arbitrary handicap to prioritize the order specified > by user, for the reasons I explained before. We should aim to make the > heuristics/costing reliable enough to make this unnecessary. +1 -- Teodor Sigaev E-mail: teodor@sigaev.ru WWW: http://www.sigaev.ru/