Re: Proposal: QUALIFY clause - Mailing list pgsql-hackers

From Isaac Morland
Subject Re: Proposal: QUALIFY clause
Date
Msg-id CAMsGm5dAYswFz5RkgEu0ZsGbEJjHaJ3QMOMPYHAGUvY_V69rCg@mail.gmail.com
Whole thread Raw
In response to Re: Proposal: QUALIFY clause  (Mike Artz <michaeleartz@gmail.com>)
Responses Re: Proposal: QUALIFY clause
Re: Proposal: QUALIFY clause
List pgsql-hackers
On Mon, 21 Jul 2025 at 10:19, Mike Artz <michaeleartz@gmail.com> wrote:
Many times I have thought it would be nice if there was a QUALIFY clause in Postgres! 

Just would like to add that including your list, Teradata, Redshift, SAP HANA, HP Vertica, and Trino all support the QUALIFY clause.

Also it seems Postgres would be the first leading RDBMS - meaning like traditional, multipurpose RDMBS - to support QUALIFY, which would be pretty cool.

Is this different from using the window functions in a subquery and then applying a WHERE clause on the outer query?

SELECT … FROM (SELECT … [including window functions] FROM …) WHERE [stuff that would be in QUALIFY]

I'll be honest, I'm skeptical that we need another keyword that basically means “WHERE, but applied at a different point in the query processing”. I'm not even convinced that HAVING was a good idea (although obviously I would not propose removal).

pgsql-hackers by date:

Previous
From: Melanie Plageman
Date:
Subject: Re: Parallel heap vacuum
Next
From: Nathan Bossart
Date:
Subject: Re: Horribly slow pg_upgrade performance with many Large Objects