Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sJOeg-004cw0-QA for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jun 2024 02:33:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sJOed-006LXV-Ub for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jun 2024 02:33:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sJOed-006LXK-Ky for pgsql-hackers@lists.postgresql.org; Tue, 18 Jun 2024 02:33:04 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sJOeX-001qFE-KH for pgsql-hackers@postgresql.org; Tue, 18 Jun 2024 02:33:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2024011501; h=Content-Type:MIME-Version:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description: In-Reply-To:References; bh=YjuYBVfXyYpqHlI0Uz5+X/ROMJGOpOjqxd1Vc60TNuQ=; b=PT F5rDkwvmHPL+RJj0YFtC41ykpHhiBHROzMSkJASGX5ynV3dU4w/gmOw+0PCmEdf9t9XAb74oIG/9k Cur2V4Rf0/0n8fzAbatOz98ltUIxwo8mFwFUaEbQrmSRDtlJFiDXzkw2TEMD1Sg/NwTrDuk0idk6w 1t3x8MML5viRSSH7glbYSD1h6G4LW5s8kwIa8NEpOM2uPFBCad5ksJfCbNqxvjU9MUMP1kahKTz5C qPdohr//enjJdZFBobL6FKHAiK58N9hRWRlelsFepJdEXouKw/RMZIIQtLG9sQHEaWiv+WiINLfp7 NeQRRwNsCO2BBW3X/+kWI1+TuhsqXIxw==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1sJOeW-00E9Oa-2M; Mon, 17 Jun 2024 22:32:56 -0400 Date: Mon, 17 Jun 2024 22:32:56 -0400 From: Bruce Momjian To: PostgreSQL-development Cc: Alexander Korotkov Subject: Missing docs for new enable_group_by_reordering GUC Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This commit added enable_group_by_reordering: commit 0452b461bc4 Author: Alexander Korotkov Date: Sun Jan 21 22:21:36 2024 +0200 Explore alternative orderings of group-by pathkeys during optimization. When evaluating a query with a multi-column GROUP BY clause, we can minimize sort operations or avoid them if we synchronize the order of GROUP BY clauses with the ORDER BY sort clause or sort order, which comes from the underlying query tree. Grouping does not imply any ordering, so we can compare the keys in arbitrary order, and a Hash Agg leverages this. But for Group Agg, we simply compared keys in the order specified in the query. This commit explores alternative ordering of the keys, trying to find a cheaper one. The ordering of group keys may interact with other parts of the query, some of which may not be known while planning the grouping. For example, there may be an explicit ORDER BY clause or some other ordering-dependent operation higher up in the query, and using the same ordering may allow using either incremental sort or even eliminating the sort entirely. The patch always keeps the ordering specified in the query, assuming the user might have additional insights. This introduces a new GUC enable_group_by_reordering so that the optimization may be disabled if needed. Discussion: https://postgr.es/m/7c79e6a5-8597-74e8-0671-1c39d124c9d6%40sigaev.ru Author: Andrei Lepikhov, Teodor Sigaev Reviewed-by: Tomas Vondra, Claudio Freire, Gavin Flower, Dmitry Dolgov Reviewed-by: Robert Haas, Pavel Borisov, David Rowley, Zhihong Yu Reviewed-by: Tom Lane, Alexander Korotkov, Richard Guo, Alena Rybakina It mentions it was added as a GUC to postgresql.conf, but I see no SGML docs for this new GUC value. Would someone please add docs for this? Thanks. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.