pg.ddx.io pgsql-performance@postgresql.org mailing list archivehelp / color / mirror / Atom feed
INNER JOIN vs WHERE 2+ messages / 2 participants [nested] [flat]
* INNER JOIN vs WHERE @ 2003-05-15 01:45 T. Alex Beamish <talexb@tabsoft.on.ca> 0 siblings, 1 reply; 2+ messages in thread From: T. Alex Beamish @ 2003-05-15 01:45 UTC (permalink / raw) To: pgsql-performance Hello, I've just had a quick search through the archives but couldn't find what I wanted, so I've joined this list to continue my search for an answer. Is there any rule of thumb about how much more efficient an INNER JOIN is compare to a regular WHERE statement? I have a couple of queries in PostgreSQL that use a variety of tables (four or five) linked together by key/foreign key conditions all ANDed together. My co-worker re-wrote one of them using the INNER JOIN approach and I wanted to find out if this would empirically improve the performance. I have not tried to do an EXPLAIN ANALYZE yet but I will try that. Thanks for your responses. Alex ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: INNER JOIN vs WHERE @ 2003-05-15 02:25 Tom Lane <tgl@sss.pgh.pa.us> parent: T. Alex Beamish <talexb@tabsoft.on.ca> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2003-05-15 02:25 UTC (permalink / raw) To: T. Alex Beamish <talexb@tabsoft.on.ca>; +Cc: pgsql-performance "T. Alex Beamish" <talexb@tabsoft.on.ca> writes: > Is there any rule of thumb about how much more efficient an INNER JOIN > is compare to a regular WHERE statement? Ideally there is no difference. If there are only two tables involved, there definitely is no difference. If there is a difference, it's because there are more than two tables, and the JOIN syntax forced a particular join order. Read http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=explicit-joins.html Typically I'd expect JOIN syntax to be a loss because the odds are good that you're forcing an inefficient join order. It could be a win only if the planner chooses a poor join order when given a free hand, or if you have so many tables that you need to suppress the planner's search for a good join order. > I have not tried to do an EXPLAIN ANALYZE yet but I will try that. If you have not bothered to do any EXPLAINs yet then you are really wasting people's time on this list. regards, tom lane ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-05-15 02:25 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2003-05-15 01:45 INNER JOIN vs WHERE T. Alex Beamish <talexb@tabsoft.on.ca> 2003-05-15 02:25 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox