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 1ufHx7-0052eh-2i for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Jul 2025 12:55:09 +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 1ufHx6-000ald-3j for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Jul 2025 12:55:08 +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 1ufHx5-000ajk-Pz for pgsql-hackers@lists.postgresql.org; Fri, 25 Jul 2025 12:55:08 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ufHx4-000iph-1f for pgsql-hackers@postgresql.org; Fri, 25 Jul 2025 12:55:07 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-748e81d37a7so1427828b3a.1 for ; Fri, 25 Jul 2025 05:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753448105; x=1754052905; darn=postgresql.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=l5qzPqGEu0HrELFwEZBATflrXUBI9BTj4upxcPsM9vI=; b=eALDfUwiKsuGZzimtXp3584+Q5UdLbAJkIUqVofgnRELm71u1/eEIb6rg6FeUDSEfH /VvTmloa25MC6j05eznZ3ncDIW0NHoI2kXhC0Mj44WsQqgLjVka8+T8pcc5hvsaBymSG TPALVFud3T9c2FPYt7xthjdOQJVIKy+GLSGYTFhwq/kKRmALt4ytISqZ4+kwKOMy4NE+ CcyP0TNWrAdJd4xl0mo6riin8qtaJxsv/5LR5TIV++/NB1RlYFAmsscUJhYGt4gHf64/ xSao2HgQxnvT84BWZdMfeHhS79USZuMa/HXZdAYM0EoakaP1PCCrO7XbwKYkwnUvfnVF Zw2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753448105; x=1754052905; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=l5qzPqGEu0HrELFwEZBATflrXUBI9BTj4upxcPsM9vI=; b=w9Yvb09Mef9XEcaGon6n77/UaIJsLo3RAP6YjFqwb6z3UlWH/ypE2dxvCL5t7hfPf3 f+3c3UKCIfT89vtJtafdPUumiVMRKa0WrRvKxf+HVYzPB2jYE4fqkFOhCUYWdgGKGnIq 6zouu60TJPcbbRGJhQIQ3m1NG3fI2v0B2SaDx6dF9b1ntiGZyXG2HTrr3skIFeFLYF/W 7So35eiS3fKwRxnqD5+0NqG6EujgxskliNeT/unl32HYxBB1UghX9aT37vm2UAGGdQQx mTjoi+8Z1cYJMHkeZhz5OncK8FUVWyvfEtqASZLqrRFpAIA5wDTiPiKQVtStapP0Rjds yf9A== X-Forwarded-Encrypted: i=1; AJvYcCWJemnsQsvNx4z/M6OjSMEd0uFXxKSfpt5dMg7sPujA8L5wODF7GKQC7guer+SX8js4XKaANmjRUn/kDyKW@postgresql.org X-Gm-Message-State: AOJu0Yye6Oy40+tYP84WiIkRIBJlqweWc535vpye4fpI8OejV7Kd5jvK hxxUyYz/9WS3AN155kGnl8xYsvLqhsHRkMxUdh+M2DbJJ4+LeOwD3rpH X-Gm-Gg: ASbGnctZLjaH560iksIUaBt/skaMpv4qFaORl+VWyKUINgM6ht19dyb67dftbzz758S bvIfgfxyWLmi2t00PKolKCEbpsZqDV4yfEnA9O/Q/NrWYAivS3mvhoLWAmIyLX2QTHLaB5OlWe8 PBHSVBs/uEcpT+3iUMWOPM9D81dFGtdY2S/AcOG7nPnTLsg4Zj9r9XNyF3ySK7CfKSVsAC17oBo PjcOxYE5vud/evkH4HaO4tafgLSNXJltXEymP4o1PtRwWix8lfTeG78g3Ajgv6nNWVkomTa5JxH fqz2o3bdgtynILwydielckYgCCOgI/J/scsX08JdWpaTZP2pr/f14nrdz9G8WlBauy1crpwxZJg v5O5HoqfJUJsTk7UZfC1h3yN/0bibH+s6uAx+OfYGhT2z9g== X-Google-Smtp-Source: AGHT+IHJPbD6YLn3g6I2IXo5qZ5H3iwr72sA+a+1L8N8bOZbbEhg/ms5GWYtvU8gJMlqQ93Mr6gqTw== X-Received: by 2002:a17:903:1aef:b0:23e:3c33:6be8 with SMTP id d9443c01a7336-23fb2fe127emr25075315ad.8.1753448105284; Fri, 25 Jul 2025 05:55:05 -0700 (PDT) Received: from localhost ([2804:14d:328a:a59c:40e7:6532:3e99:be49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fa4901b16sm36568785ad.183.2025.07.25.05.55.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Jul 2025 05:55:04 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 25 Jul 2025 09:55:01 -0300 Message-Id: Cc: "Peter Eisentraut" Subject: Re: Proposal: QUALIFY clause From: "Matheus Alcantara" To: "Vik Fearing" , "Pg Hackers" X-Mailer: aerc 0.20.1 References: <6c998e4f-f6f2-43c2-8b67-cfff360ef241@postgresfriends.org> In-Reply-To: <6c998e4f-f6f2-43c2-8b67-cfff360ef241@postgresfriends.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon Jul 21, 2025 at 7:11 PM -03, Vik Fearing wrote: > That is my preferred grammar, thank you.=C2=A0 I have not looked at the C= =20 > code by this can be obtained with a syntax transformation. To wit: > > > SELECT a, b, c > FROM tab > QUALIFY wf() OVER () =3D ? > > > can be rewritten as: > > > SELECT a, b, c > FROM ( > =C2=A0 =C2=A0 SELECT a, b, c, wf() OVER () =3D ? AS qc > =C2=A0 =C2=A0 FROM tab > ) AS q > WHERE qc > > > and then let the optimizer take over.=C2=A0 The standard does this kind o= f=20 > thing all over the place; I don't know what the postgres project's=20 > position on doing things like this are. > With this transformation users will see a Subquery plan node even if it's not present on the original query, is that expected or it can be confusing to users? -- Matheus Alcantara