Re: join vs exists

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <rummandba(at)gmail(dot)com>,<pgsql-performance(at)postgresql(dot)org>
Subject: Re: join vs exists
Date: 2010-06-20 15:02:18
Message-ID: 4C1DE72A020000250003263B@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

AI Rumman wrote:

> Which one is good - join between table or using exists in where
> condition?

Your example wouldn't return the same results unless there was at
most one matching row in b and one matching row in c, at least
without resorting to DISTINCT (which you don't show). So, be careful
of not getting the wrong results in an attempt to optimize.

You don't say which version of PostgreSQL you're using, but if its a
fairly recent major version, I would expect nearly identical
performance if the queries returned the same results without
DISTINCT, and would usually expect better results for the EXISTS than
the JOIN with DISTINCT.

-Kevin

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2010-06-20 15:21:07 Re: Slow function in queries SELECT clause.
Previous Message Dave Crooke 2010-06-20 14:22:13 Re: Obtaining the exact size of the database.