Re: where clauses and multiple tables

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: where clauses and multiple tables
Date: 2009-09-09 01:50:49
Message-ID: 4AA709F9.7010103@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yaroslav Tykhiy wrote:
> By the way, folks, do you think there may be performance gain or loss
> from rewriting this with an explicit JOIN? E.g.:
>
> SELECT DISTINCT foo.foo_id, foo.name FROM foo JOIN bar ON foo.bar_id =
> bar.bar_id WHERE bar.name='martini';

I would expect that to be more efficient as its the 'proper' SQL way of
doing things, and the optimizer will do a better job on it, especially
if foo.bar_id is a FK to bar.bar_id's primary key.

btw, can't this be written...

SELECT DISTINCT foo.foo_id, foo.name
FROM foo JOIN bar ON bar_id
WHERE bar.name='martini';

?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-09-09 03:13:59 Re: Using symbolic links with tablespaces
Previous Message Yaroslav Tykhiy 2009-09-09 01:38:17 Re: Can I Save images in postgres?