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 1spANF-00H7d8-Gm for pgsql-general@arkaria.postgresql.org; Fri, 13 Sep 2024 17:46:26 +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 1spANE-008Qle-SY for pgsql-general@arkaria.postgresql.org; Fri, 13 Sep 2024 17:46:24 +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 1spANE-008QlV-Gx for pgsql-general@lists.postgresql.org; Fri, 13 Sep 2024 17:46:24 +0000 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1spANA-00101A-Sv for pgsql-general@lists.postgresql.org; Fri, 13 Sep 2024 17:46:23 +0000 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-27bb27a68d5so1237684fac.3 for ; Fri, 13 Sep 2024 10:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726249580; x=1726854380; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2DEf9jBbk6GSZAsQFQpLwQlrFqJBfof9MI9tLMhJNak=; b=dUgZvg/kJQImo/tX9aoqXsSSH5QvuZgYSzuVVhlU1spHwBUvfqnjSKKvoX4eas5qYJ TpmZImSL3vo3RVeAsJIkCXd2fhvToQWWLz4fBxYB5otUqOqAj4qEAJJOURPjAke9rZ7o BRU7er7UiJXQhGtTbTlTm2McPksOvHGm9bdNR+slDaizb1GRB+WGLXNMOgyjtD91BD8O g21BTKHtp66M8YhcSdYWnVDWr8KccSPt41zbR3kH/fpn5bbIjqePc0M+ar0ptfPqXVyK bKFipJfzcUJUs6G9JlPIzgTGkjLzj6Kbr2wcHxtAlQo5dpu/UEPqmoQfTRtM1MNbBBDy VzIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726249580; x=1726854380; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2DEf9jBbk6GSZAsQFQpLwQlrFqJBfof9MI9tLMhJNak=; b=vIbHCBtxUWSoql4Frq6LZbZvtv95169G0hsk5/ge+N1+wa6K77BMflFxh7szWs5ilU nis0LOZEEszPQPKmniplRLex3uNUuptF9dU1P2WRmjyJ5HzhLnv4z/uSNvizoljvGlTO t65xQhdwAsv2Ca70mxnD7z+o3K0HWmzXwbg897QyHZn8TeNEvgf5Gad697WZOgsMiiMf qF51rdEh+wj6bdYhA6F2c4OEQkJ3Rdxa7SqaYX6n6ffWZA6XxwF+4AdJTlZGamK97CvC EuL2m1qUXdHs1+yDKmGDHaPwRQ8OF0cJMphKsuG3+DSvGB/dtvFduuYS8y7VAWExdjjr JwmQ== X-Forwarded-Encrypted: i=1; AJvYcCWhErI8D7whwMBwoVkBqIHjvC9QmuTIurhj4TGs2349IvkRNONrqrctFGwxlYkQbMAIimTOKpho1L1dYTks@lists.postgresql.org X-Gm-Message-State: AOJu0YwCOek81MpeP97klFKXTmHKZ091QqCtM4nq0Ki+VHjI6ymgxT2h JtD9tTf3cGEypBctSoUkvCsK21duvN9CIejZlFLZiFuBv2QW0ZFnE5uF4lhjeO1zmJA4myZGufV DF/nmhPATnhcmY/sNNfe+pE6Nf5I= X-Google-Smtp-Source: AGHT+IH5QHXQ7m7bMK0MQJ3G+mjPHUuLQ+eemR+hLN5i7XiA3PJyJf2yOWxUxKo7M6CAnT6WiNU9+fI+TEArO6w3CXQ= X-Received: by 2002:a05:6870:610e:b0:277:cc6e:15de with SMTP id 586e51a60fabf-27c3f0ededfmr4774534fac.4.1726249580224; Fri, 13 Sep 2024 10:46:20 -0700 (PDT) MIME-Version: 1.0 References: <88e52d11-6185-473d-9eb2-673b62cb2426@gmx.net> In-Reply-To: From: "David G. Johnston" Date: Fri, 13 Sep 2024 10:46:10 -0700 Message-ID: Subject: Re: Functionally dependent columns in SELECT DISTINCT To: Willow Chargin Cc: shammat@gmx.net, pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000005e959062203cd27" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000005e959062203cd27 Content-Type: text/plain; charset="UTF-8" > > > > > or use a lateral subquery to surgically (fetch first 1) retrieve the > first row when sorted by recency descending. > > I'm not sure that I see how to apply this when I need top-k, not top-1. > Fetch first k It's just a modern limit clause. David J. --00000000000005e959062203cd27 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


> or use a lateral subquery to surgically (fetch first 1) retrieve the f= irst row when sorted by recency descending.

I'm not sure that I see how to apply this when I need top-k, not top-1.=

= Fetch first k

It's j= ust a modern limit clause.

David J.
--00000000000005e959062203cd27--