RE: [GENERAL] Simulating an outer join

From: "Culberson, Philip" <philip(dot)culberson(at)dat(dot)com>
To: "'Bruce Momjian'" <pgman(at)candle(dot)pha(dot)pa(dot)us>, Julian Scarfe <jscarfe(at)callnetuk(dot)com>
Cc: PostgreSQL-general <pgsql-general(at)postgreSQL(dot)org>
Subject: RE: [GENERAL] Simulating an outer join
Date: 2000-01-13 17:11:39
Message-ID: A95EFC3B707BD311986C00A0C9E95B6A04B3ED@datmail03.dat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

How about no column at all? I see Oracle do a lot of these. Maybe for
referential integrity checks?

test1=> select 'WORKS!' as "Result" from geo
test1-> where EXISTS (select null from geo where city = 'Portland' and state
= 'OR');
Result
------
WORKS!
(1 row)

-----Original Message-----
From: Bruce Momjian [mailto:pgman(at)candle(dot)pha(dot)pa(dot)us]
Sent: Thursday, January 13, 2000 5:07 AM
To: Julian Scarfe
Cc: PostgreSQL-general
Subject: Re: [GENERAL] Simulating an outer join

> Bruce Momjian wrote:
>
> > I am just writing the EXISTS section from my book. I don't think it
> > matters what fields are returned from an EXISTS subquery. If I am
> > wrong, someone please let me know.
>
> Celko also writes (in his chapter on EXISTS in "SQL for Smarties"):
>
> "In general the SELECT * option should perform better than the actual
column.
> It lets the query optimizer decide which column to use. If a column has
an
> index on it, then simply seeing a pointer to the index is enough to
determine
> that something exists."
>
> Obviously you're in a much better position than me to judge whether that's
the
> case in pgsql! But it might be worth a test.

In psql, I think * would generate all the columns, then throw it away,
while a specific column would only carry around that column in the
subquery result. so a single column is better.

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

************

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2000-01-13 17:18:46 Re: [GENERAL] oid data typeu
Previous Message Patrick Welche 2000-01-13 15:58:05 Re: [GENERAL] Default date format to ISO + 1 bug