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 1jRx9v-0005zE-CW for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Apr 2020 12:10:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jRx9u-0000Db-7E for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Apr 2020 12:10:18 +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 1jRx9t-00008R-S2 for pgsql-hackers@lists.postgresql.org; Fri, 24 Apr 2020 12:10:18 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jRx9n-0006Is-2t for pgsql-hackers@postgresql.org; Fri, 24 Apr 2020 12:10:16 +0000 Received: by mail-wm1-x329.google.com with SMTP id g12so10411889wmh.3 for ; Fri, 24 Apr 2020 05:10:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:in-reply-to:references:comments:mime-version :content-id:content-transfer-encoding:date:message-id; bh=iw7ajhwgG5vVMr0shgReFWFTsXW7BRA5jSqowhtvPr4=; b=uzOOxoiudSuOJkl2D6SsWsyP+keeJBMrmbgSfWur/eT4RLFNJyvWUl6sL48naasqG3 MlcSWDntMKur80f5m15oNIBVB/KSj1UGAtKY+8fyrOv2jvyZWkMhia5fhlMB75S+ONJz paYJ0aEhNsdPnIZwORCIF9gZ3BDvNbPptAJGLN3VGDRfcSvwESCxS95boLTURkGk+0NW k31EroSs1cpJg2yOwhUnzXUgErlAnYASPBznub0N/ihGmlfygxb2+2MNH4W0m1UNkL0Z lb+9Xpt4bwwsc6/xGyRgc9/D0LmvN5EnrTpC/ZH3W86vQ9hk/PfaEiwLp9/mGYIfMHeG ONeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :comments:mime-version:content-id:content-transfer-encoding:date :message-id; bh=iw7ajhwgG5vVMr0shgReFWFTsXW7BRA5jSqowhtvPr4=; b=Gak9bTCerQfe7z5VCK56Ta04GuBhuTpIV6BnZ/HSR3Rb0uVLvZTVRukbDaBqiYGPzN Cd6i5B+8smkaRVPTd0E36CVzCjs2Ue38ZRAyJH6yp1ugEQ/op3whqJ7Tt2QsWTeBPbdl wA5WBI/cci/HuJ4ah3Q7wO6FbEO5TO+yh9SzgKAfNHAgocSfwjPaUy8zeBbIPb5w7FnS H43nUt/Fiucn3pa7Hhr8Ixz9pDloDjQMzyWuw8tF7b0R43nC+i53Zif0r8HmP1p8GZZe Ljx7zB1ZPkrdWCP/azOgkbXKjXOBrf5b73pKq0y7hiN+FHkguvsGtNI7hE3oonXB/L5G vMRw== X-Gm-Message-State: AGi0PuY2i4dxtW+CFzX/rt/7EmmYh17v/SgI3Q8TrIcRiYCz7DPiusLR oELdyCG4p26PFcOoi2Exb95ixg== X-Google-Smtp-Source: APiQypLWp/11RWKXe+qe4ycyt2iGiS91LLm0PMFI5mCNuo+dUPLwRZRgRHGXAglDl8iTS4IhDgdRbg== X-Received: by 2002:a1c:5502:: with SMTP id j2mr10407174wmb.56.1587730208662; Fri, 24 Apr 2020 05:10:08 -0700 (PDT) Received: from antos ([77.87.240.5]) by smtp.gmail.com with ESMTPSA id c20sm2892996wmd.36.2020.04.24.05.10.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 05:10:08 -0700 (PDT) From: Antonin Houska To: Andy Fan cc: legrand legrand , pgsql-hackers Subject: Re: WIP: Aggregation push-down In-reply-to: References: <11172.1550780283@sss.pgh.pa.us> <23468.1551369774@localhost> <1897.1562680064@spoje.net> <13971.1562920911@spoje.net> <19857.1563374392@localhost> <20190904202339.GA13644@alvherre.pgsql> <7087.1567663858@localhost> <1582751446111-0.post@n3.nabble.com> <20715.1582793501@antos> Comments: In-reply-to Andy Fan message dated "Tue, 21 Apr 2020 16:37:25 +0800." X-Mailer: MH-E 8.6+git; nmh 1.7; GNU Emacs 26.3.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <50401.1587730290.1@antos> Content-Transfer-Encoding: quoted-printable Date: Fri, 24 Apr 2020 14:11:30 +0200 Message-ID: <50402.1587730290@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andy Fan wrote: > The more tests on your patch, the more powerful I feel it is! Thanks for the appreciation. Given the poor progress it's increasingly har= d for me to find motivation to work on it. I'll try to be more professional = :-) > At the same time, I think the most difficult part to understand your des= ign > is you can accept any number of generic join clauses, so I guess more > explanation on this part may be helpful. ok, I'll consider adding some comments, although the concept is mentioned = in optimizer/README +Furthermore, extra grouping columns can be added to the partial Agg node = if a +join clause above that node references a column which is not in the query +GROUP BY clause and which could not be derived using equivalence class. + ... > At the code level, I did some slight changes on init_grouping_targets wh= ich may > make the code easier to read. You are free to to use/not use it. I'm going to accept your change of create_rel_agg_info(), but I hesitate a= bout the changes to init_grouping_targets(). First, is it worth to spend CPU cycles on construction of an extra list grouping_columns? Is there a corner case in which we cannot simply pass grouping_columns=3Dtarget->exprs to check_functional_grouping()? Second, it's obvious that you prefer the style foreach () { if () ... else if () ... else ... } over this foreach () { if () { ... continue; } if () { ... continue; } ... } I often prefer the latter and I see that the existing planner code uses th= is style quite often too. I think the reason is that it allows for more compl= ex tests, while the "else-if style" requires all tests to take place inside t= he "if ()" expression. However, if several (not necessarily tightly related) tests become "compressed" this way, it's less obvious how where to put comments. Indeed it seems that some comments got lost due to your changes= . -- = Antonin Houska Web: https://www.cybertec-postgresql.com