Doc: improve user docs and code comments about EXISTS(SELECT * ...).
Point out that Postgres automatically optimizes away the target list
of an EXISTS' subquery, except in weird cases such as target lists
containing set-returning functions. Thus, both common conventions
EXISTS(SELECT * FROM ...) and EXISTS(SELECT 1 FROM ...) are
overhead-free and there's little reason to prefer one over the other.
In the code comments, mention that the SQL spec says that
EXISTS(SELECT * FROM ...) should be interpreted as EXISTS(SELECT
some-literal FROM ...), but we don't choose to do it exactly that way.
Author: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/9b301c70-3909-4f0f-98ca-9e3c4d142f3e@eisentraut.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/65a3ff8f1be0186a9c207821bcf0f543545a04d9
Modified Files
--------------
doc/src/sgml/func/func-subquery.sgml | 10 ++++++++--
src/backend/optimizer/plan/subselect.c | 8 +++++++-
2 files changed, 15 insertions(+), 3 deletions(-)