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 1kXVRr-00038h-Sa for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Oct 2020 20:20:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kXVRq-000303-RK for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Oct 2020 20:20:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXVRq-0002zv-LB for pgsql-hackers@lists.postgresql.org; Tue, 27 Oct 2020 20:20:02 +0000 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kXVRj-0001Mu-KC for pgsql-hackers@lists.postgresql.org; Tue, 27 Oct 2020 20:20:02 +0000 Received: by mail-ej1-x641.google.com with SMTP id za3so14495ejb.5 for ; Tue, 27 Oct 2020 13:19:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=iO5uF3VW9DXihzWII38dt/FHb+3RoFgVVR61xTRAJ54=; b=Oq1JLtt7918C6LbtolEJft1Wr8f7MLmzuXPlpY4y/7kN96wMYDIc4ujbj8gUkP8icW ryK55pWM00wtnGGIN8s0DfTPH4EiqTzeAHvApyzarvhoZy/u2XAvS5xFU4XK9gCLiLlu AQa77seKjTcA52wfioM5sW40xy55dtMed8yF9qtD1TkGG2DGaIsNm1r2cMsnrhxG7Tsg 0N4HDNYxNiaJo1SUm6hpGOdB1AxMKSsOGFwoe6O6ThkM5PhSlNmrLHGqnpdEbGQGcXNo smrQRQWeIo4Xhxg5s2DHzBHeepZAQuSl9HAC+vpr3t8dTcSftGUXcOBgti3mGjjPSciF p32w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iO5uF3VW9DXihzWII38dt/FHb+3RoFgVVR61xTRAJ54=; b=rAyKxgZwjVLcNBypvBihYLjXqy+JjO1ngZXJCp9DmmHcYBniIq1Pbk+y8kvZ5ISA25 LZoGRtmRAD7+Pl1NhO3rGDW/PT8WQZt305VmzwhisWhBwUDx9W8jJWPOKiEtzG1yfmBx H+eue0m5z2VlzyM2f4LwSKzhPh2mxIx2LN2iH7LNM2q5RpChSmnc3SX1q/Jr8CVGwvsu 7RM8PD6RgsFTe+04uZVH9Ke9TbVtRPOraUKCXMtUq/tQlyEpar81e1AlG06E8eCQLfMB nz/Qk0M07mFid7xxuTtJUUiuy+e0iRYuGDInJLB6jMxX1gGGYIHwUdiFxnnpNfRtQOks p1mg== X-Gm-Message-State: AOAM530HSptmjD8SFif2xTbk1/edtOhJydI8GiHKNFLTPeLCsy8x1uXZ fRjEE3BpzH3fbUczHDrv6jhM7g== X-Google-Smtp-Source: ABdhPJze8BXhekEBWp8mbJgTBAP88DRTGkL5Delqmli1wiGTk2u3BJR6QASUvvGwaMboCAZyzRkoDQ== X-Received: by 2002:a17:906:3092:: with SMTP id 18mr4159705ejv.43.1603829993854; Tue, 27 Oct 2020 13:19:53 -0700 (PDT) Received: from localhost (ip-86-49-245-76.net.upcbroadband.cz. [86.49.245.76]) by smtp.gmail.com with ESMTPSA id oz18sm1650320ejb.55.2020.10.27.13.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 13:19:53 -0700 (PDT) Date: Tue, 27 Oct 2020 21:19:51 +0100 From: Tomas Vondra To: Dmitry Dolgov <9erthalion6@gmail.com> Cc: Pavel Borisov , Teodor Sigaev , Gavin Flower , Andres Freund , Michael Paquier , PostgreSQL Developers Subject: Re: POC: GROUP BY optimization Message-ID: <20201027201509.jfv6sfhrmxhdwlvk@development> References: <20190409152100.5q25whnxs27zws5m@development> <20190503215510.bcr5ycszntqg65tw@development> <20190524225725.embuha33qvc5avz3@development> <20200514235220.xewrrwjvatxzn3g6@development> <20201026085721.g6h5xljxvodnmk34@localhost> <20201026104040.6bigvej6f55vjvgp@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20201026104040.6bigvej6f55vjvgp@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Oct 26, 2020 at 11:40:40AM +0100, Dmitry Dolgov wrote: >> On Mon, Oct 26, 2020 at 01:28:59PM +0400, Pavel Borisov wrote: >> > Thanks for your interest! FYI there is a new thread about this topic [1] >> > with the next version of the patch and more commentaries (I've created >> > it for visibility purposes, but probably it also created some confusion, >> > sorry for that). >> > >> > Thanks! >> >> I made a very quick look at your updates and noticed that it is intended to >> be simple and some parts of the code are removed as they have little test >> coverage. I'd propose vice versa to increase test coverage to enjoy more >> precise cost calculation and probably partial grouping. >> >> Or maybe it's worth to benchmark both patches and then re-decide what we >> want more to have a more complicated or a simpler version. >> >> Good to know that this feature is not stuck anymore and we have more than >> one proposal. >> Thanks! > >Just to clarify, the patch that I've posted in another thread mentioned >above is not an alternative proposal, but a development of the same >patch I had posted in this thread. As mentioned in [1], reduce of >functionality is an attempt to reduce the scope, and as soon as the base >functionality looks good enough it will be returned back. > I find it hard to follow two similar threads trying to do the same (or very similar) things in different ways. Is there any chance to join forces and produce a single patch series merging the changes? With the "basic" functionality at the beginning, then patches with the more complex stuff. That's the usual way, I think. As I said in my response on the other thread [1], I think constructing additional paths with alternative orderings of pathkeys is the right approach. Otherwise we can't really deal with optimizations above the place where we consider this optimization. That's essentially what I was trying in explain May 16 response [2] when I actually said this: So I don't think there will be a single "interesting" grouping pathkeys (i.e. root->group_pathkeys), but a collection of pathkeys. And we'll need to build grouping paths for all of those, and leave the planner to eventually pick the one giving us the cheapest plan. I wouldn't go as far as saying the approach in this patch (i.e. picking one particular ordering) is doomed, but it's going to be very hard to make it work reliably. Even if we get the costing *at this node* right, who knows how it'll affect costing of the nodes above us? So if I can suggest something, I'd merge the two patches, adopting the path-based approach. With the very basic functionality/costing in the first patch, and the more advanced stuff in additional patches. Does that make sense? regards [1] https://www.postgresql.org/message-id/20200901210743.lutgvnfzntvhuban%40development [2] https://www.postgresql.org/message-id/20200516145609.vm7nrqy7frj4ha6r%40development -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services