Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsTh6-0006S5-Id for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jul 2019 15:05:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hsTh5-0007Cy-ED for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jul 2019 15:05:39 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsTh4-0007C6-W4 for pgsql-hackers@lists.postgresql.org; Tue, 30 Jul 2019 15:05:39 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsTh2-0005nN-3s for pgsql-hackers@postgresql.org; Tue, 30 Jul 2019 15:05:38 +0000 Received: by mail-wr1-x444.google.com with SMTP id y4so66177488wrm.2 for ; Tue, 30 Jul 2019 08:05:35 -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:user-agent; bh=fRpEzW5u8dr8Crg7Oadfr+K24TFjd1xg7JH4vxJgOfg=; b=bxc6//nG6siC8BiLRPhAsbYCEFglgDzBOkfKd+jg65ewmA3YqKlhldFWvgVA8uTelC Yv1qLMEluAuxvemFB0vfcqPj0aGoHEbihs1YVf/23/1Ce5Ud2G8SrsUZFjc6jvqczeob Ioq9nljqEXdR/jdOr+bHuw8QJg89Y396HPk6KG6Uq6jSmSPsz6hkvNDHm5q61fd477I7 0ZgRD30393DiQ7EA3PzIobbRFhhKIaSUs6WoSWKP/12XqhMd6iQSWnpvhRgQ082xgR+t yIkGQSy3ZYYgaZMon6+6QQuNwSMGFL/HKtTiyQ7Rmo3KVlXuQLl2jK6OFTJcgBykwmCy toGA== 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:user-agent; bh=fRpEzW5u8dr8Crg7Oadfr+K24TFjd1xg7JH4vxJgOfg=; b=E4tU7Fx8RvKAmxnamqWZ/JB9rWWdPuSLHQGOTyUw+V/++0VcHrS6EINIk1oMHsTCH6 3543kVtdzYXi+mFejuMen6hKIa8C6KqRZQ1vDiRMT2Z9ntIBz/FFBugiJkanWpFiwPPp gyQTT498quk7519epS1MFgoYaJPaNoezmqRJO4YUb9Sy2ZP8ng8uSat2QvbuUK0bBx9+ liqawQ0lFs/6eYbObzVAc/rb+BhwjKyhYv5eg3rsGDJcnmsPB7FCECvVJsfcqkPGSx7D 3a/m8tx0sWUc96xHHQeYhkJfSTzYEEhyeyOje5mGoTfwVnCYphDHIlBez5sKVefjYr4E 6s8w== X-Gm-Message-State: APjAAAUVEOKOBeZTaYXTdsV4Edv7xB7Xrqvih6osQKj49p0O99VbcTiJ keNtQX1PJHzfhFaJi2fyzCuXEw== X-Google-Smtp-Source: APXvYqwpDOF/UtQLWnfH9bD4RFuRObfyoDV4qtpkPizwAmy1S+6g9Qf8ceEbZgyp6kqnnQwyzGKh0Q== X-Received: by 2002:a5d:4f01:: with SMTP id c1mr47183045wru.43.1564499133611; Tue, 30 Jul 2019 08:05:33 -0700 (PDT) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id x8sm54289732wmc.5.2019.07.30.08.05.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 30 Jul 2019 08:05:32 -0700 (PDT) Date: Tue, 30 Jul 2019 17:05:30 +0200 From: Tomas Vondra To: Richard Guo Cc: PostgreSQL-development Subject: Re: Parallel grouping sets Message-ID: <20190730150530.rfu5yw2g2q2lixse@development> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-1444-295967-dirty List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Jul 30, 2019 at 03:50:32PM +0800, Richard Guo wrote: >On Wed, Jun 12, 2019 at 10:58 AM Richard Guo wrote: > >> Hi all, >> >> Paul and I have been hacking recently to implement parallel grouping >> sets, and here we have two implementations. >> >> Implementation 1 >> ================ >> >> Attached is the patch and also there is a github branch [1] for this >> work. >> > >Rebased with the latest master. > Hi Richard, thanks for the rebased patch. I think the patch is mostly fine (at least I don't see any serious issues). A couple minor comments: 1) I think get_number_of_groups() would deserve a short explanation why it's OK to handle (non-partial) grouping sets and regular GROUP BY in the same branch. Before these cases were clearly separated, now it seems a bit mixed up and it may not be immediately obvious why it's OK. 2) There are new regression tests, but they are not added to any schedule (parallel or serial), and so are not executed as part of "make check". I suppose this is a mistake. 3) The regression tests do check plan and results like this: EXPLAIN (COSTS OFF, VERBOSE) SELECT ...; SELECT ... ORDER BY 1, 2, 3; which however means that the query might easily use a different plan than what's verified in the eplain (thanks to the additional ORDER BY clause). So I think this should explain and execute the same query. (In this case the plans seems to be the same, but that may easily change in the future, and we could miss it here, failing to verify the results.) 4) It might be a good idea to check the negative case too, i.e. a query on data set that we should not parallelize (because the number of partial groups would be too high). Do you have any plans to hack on the second approach too? AFAICS those two approaches are complementary (address different data sets / queries), and it would be nice to have both. One of the things I've been wondering is if we need to invent gset_id as a new concept, or if we could simply use the existing GROUPING() function - that uniquely identifies the grouping set. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services