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 1m410N-0000tY-1v for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jul 2021 13:02: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 1m410M-0004Ny-1a for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jul 2021 13:02: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 1m410L-0004Nq-P4 for pgsql-hackers@lists.postgresql.org; Thu, 15 Jul 2021 13:02:17 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m410J-00082v-S2 for pgsql-hackers@lists.postgresql.org; Thu, 15 Jul 2021 13:02:16 +0000 Received: by mail-wr1-x42a.google.com with SMTP id k4so7652313wrc.8 for ; Thu, 15 Jul 2021 06:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aiven.io; s=google; h=from:to:cc:subject:date:message-id:organization:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wstz8kSxaXo/Bx7i8X5t5mB6FN87K4UGawCaPb4sKMw=; b=MCGcC/8EE7ZuHkh4oXLhGt50pzr1k1y80nwKi0UWkletxKbp2Y90avw4/DZGEBoe4E Vu258R7Y/lX8bdctywDZJKYi3kGJmMisDieIknQQsxylp97HYVnxos1EWXKwDhcUl15A bfeSZ44K06Hwa5W4EDom0R9cEDg0iK9vVMS64= 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:date:message-id:organization :in-reply-to:references:mime-version:content-transfer-encoding; bh=Wstz8kSxaXo/Bx7i8X5t5mB6FN87K4UGawCaPb4sKMw=; b=jWVyO/XkhjdV/9SMnzh0/4h0Fj7wZMKMn3DsBW5AKBstTupgKeROgb4kcTgscVn85Z rdyVbQWhcIiW0P+yQyijfbdunkFv6hBb7QO1vjwxXoXq2KxgCUSo1C73w058ORHP/tWu ufQRx96bj83L/Dfb8SpnzFaKyMnW/LhdgHUNfBqmSP7MIPI1y0Opz+CvFEwmo32lM+bQ zalDoVHzUv9jBUP/5Q65f53pIWGhHyxedB8NkULO72B0tRL6tUQX9qWxVjpgnozepZ+N Pt3uaWU3iiFWjfPBQRxIGKbOVoyTjZaxuaugN6zjIfkojz62blWrPMKS/0LFrJgM8MnR wJlw== X-Gm-Message-State: AOAM533zMDjhzias2gVKkSvFr1eNMCbwH8MCaoxlNRJpzGhbKQ6Sos4S MHVbHxMiQlWTusOhz9CzVhikyeqQYbeYFaeo X-Google-Smtp-Source: ABdhPJzdayWhLyzNRmY/oPqS7ByKoedS6y2udIcxE6sRs4VjcRLR9sfNms4SFHKSkZUsR//rcowLqw== X-Received: by 2002:a5d:46cc:: with SMTP id g12mr5283881wrs.136.1626354134265; Thu, 15 Jul 2021 06:02:14 -0700 (PDT) Received: from aivenronan.localnet (static-176-158-121-96.ftth.abo.bbox.fr. [176.158.121.96]) by smtp.gmail.com with ESMTPSA id y13sm6359977wrp.80.2021.07.15.06.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 06:02:13 -0700 (PDT) From: Ronan Dunklau To: pgsql-hackers@lists.postgresql.org, David Rowley Cc: Ranier Vilela Subject: Re: Add proper planner support for ORDER BY / DISTINCT aggregates Date: Thu, 15 Jul 2021 15:02:00 +0200 Message-ID: <2746808.Lq6AjvN2yG@aivenronan> Organization: aiven In-Reply-To: References: 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 13 juillet 2021, 06:44:12 CEST David Rowley a =E9crit : > I've attached the updated patches. The approach of building a pathkey for the first order by we find, then=20 appending to it as needed seems sensible but I'm a bit worried about users= =20 starting to rely on this as an optimization. Even if we don't document it,= =20 people may start to change the order of their target lists to "force" a=20 specific sort on the lower nodes. How confident are we that we won't change= this=20 or that we will be willing to break it ? Generating all possible pathkeys and costing the resulting plans would be t= oo=20 expensive, but maybe a more "stable" (and limited) approach would be fine, = like=20 generating the pathkeys only if every ordered aggref shares the same prefix= =2E I=20 don't think there would be any ambiguity here. =2D-=20 Ronan Dunklau