Re: Optimize SELECT * in EXISTS

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Optimize SELECT * in EXISTS
Date: 2026-02-23 08:41:22
Message-ID: CAApHDvprYAAA1szsC3+OYWss4ALJp0wG7Qbw8Zu+s7pq1gm3yA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 23 Feb 2026 at 21:21, Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
> I read in the SQL standard that SELECT * in EXISTS is not supposed to be
> expanded to all columns, but only to an arbitrary literal. This
> corresponds to the recommendation in the PostgreSQL documentation to
> write EXISTS (SELECT 1 ...) instead. But not even our own tests and
> example code use that latter convention consistently, so I think many
> users don't know it or observe it either. So implementing that little
> optimization for SELECT * seems reasonable.

> Thoughts?

Don't we already do this in simplify_EXISTS_query()?

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mahendra Singh Thalor 2026-02-23 08:58:43 Re: Non-text mode for pg_dumpall
Previous Message Peter Eisentraut 2026-02-23 08:21:15 Optimize SELECT * in EXISTS