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 1osKDD-0004vq-LX for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Nov 2022 08:44:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1osKDC-0001Z8-I4 for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Nov 2022 08:44: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 1osKDC-0001XM-6N for pgsql-hackers@lists.postgresql.org; Tue, 08 Nov 2022 08:44:02 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1osKDA-0006wD-7M for pgsql-hackers@lists.postgresql.org; Tue, 08 Nov 2022 08:44:01 +0000 Received: by mail-wr1-x42d.google.com with SMTP id y16so19737254wrt.12 for ; Tue, 08 Nov 2022 00:43:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aiven.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4iEQi0E/duzn4wTveQ6Ml3HTweIH0uRqozPG2c1SBLs=; b=L83sk/pyMLpKiusdAV/1jFeZqGRFD+z8dIytfgj91dAzXRZt9tBkobe6kt7Iq6uUv/ 9DunDdwtETmtkfxtgKYerVvxA7EX/wC5jQCv4uvslNJzAPp6p7mNmORl/EoPJewgBTGe YpeMdEGPZD2YbjUgU4xgLX/d1it7GubMp7ODo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4iEQi0E/duzn4wTveQ6Ml3HTweIH0uRqozPG2c1SBLs=; b=JirarPgcf3zNTZvnRI7V5FuB/eIhWjC1FjseLw7ej/KsdJbxTo7AIDxWIzb3BCYolk JcnyBB3Y4UuHJL/L+p7oYufX7myoq9iVgxfxhwLhKlAh8T4Z4Pcbl5LTLphZQvQYVCeS miW6Nt6i7Bf1hJg0VqJFPs/w/77pv4cqKuT/WCx/o7jOmhgfEix2cO+ugx+varReFm4N U4T+Q4IJWgvHuTmi4J7MhBsB8AT4skuHndgb3uVrNOARvJ4wrEEUpqJnap2eNM0mxJak Dogyg7Yn5y1uGPQ4VP+kV5ERD98DzWpY+LU03anj9csoXND2mxUtrP+ikION7atYHc+E QlnA== X-Gm-Message-State: ACrzQf3Mjx9Uqh+lHIOm5ZRawps2GyjXv+WEIG5ug8vEqOVnWj88DuK3 +7RRx1pxvEoFZzV12w3/G+8rSg== X-Google-Smtp-Source: AMsMyM4434oXG8mBbHI3Kfgjqu6BheUr1FmEW8PPd8B/7S3Mug+bfEjD9uQIEvwePXM3MnAi9KHakA== X-Received: by 2002:adf:b608:0:b0:236:d95e:2b1 with SMTP id f8-20020adfb608000000b00236d95e02b1mr26608232wre.569.1667897037709; Tue, 08 Nov 2022 00:43:57 -0800 (PST) Received: from aivenlaptop.localnet ([45.13.105.93]) by smtp.gmail.com with ESMTPSA id j27-20020a05600c1c1b00b003a8434530bbsm14911428wms.13.2022.11.08.00.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 00:43:57 -0800 (PST) From: Ronan Dunklau To: David Rowley Cc: Justin Pryzby , Pavel Luzanov , Tom Lane , Richard Guo , pgsql-hackers@lists.postgresql.org, Ranier Vilela Subject: Re: Add proper planner support for ORDER BY / DISTINCT aggregates Date: Tue, 08 Nov 2022 09:43:57 +0100 Message-ID: <5773143.MhkbZ0Pkbq@aivenlaptop> In-Reply-To: References: <3163474.aeNJFYEL58@aivenronan> <2202180.iZASKD2KPV@aivenlaptop> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Le mardi 8 novembre 2022, 02:31:12 CET David Rowley a =E9crit : > 1. Adjusts add_paths_to_grouping_rel so that we don't add a Sort path > when we can add an Incremental Sort path instead. This removes quite a > few redundant lines of code. This seems sensible > 2. Removes the * 1.5 fuzz-factor in cost_incremental_sort() > 3. Does various other code tidy stuff in cost_incremental_sort(). > 4. Removes the test from incremental_sort.sql that was ensuring the > inferior Sort -> Sort plan was being used instead of the superior Sort > -> Incremental Sort plan. >=20 > I'm not really that 100% confident in the removal of the * 1.5 thing. > I wonder if there's some reason we're not considering that might cause > a performance regression if we're to remove it. I'm not sure about it either. It seems to me that we were afraid of=20 regressions, and having this overcharged just made us miss a new optimizati= on=20 without changing existing plans. With ordered aggregates, the balance is a = bit=20 trickier and we are at risk of either regressing on aggregate plans, or mor= e=20 common ordered ones. =2D- Ronan Dunklau