Query optimization with X Y JOIN

From: J(at)Planeti(dot)Biz
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Query optimization with X Y JOIN
Date: 2006-01-26 15:43:12
Message-ID: 005d01c6228f$3772dca0$0d310d05@fatchubby
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance pgsql-sql

Hey guys, how u been. This is quite a newbie question, but I need to ask it. I'm trying to wrap my mind around the syntax of join and why and when to use it. I understand the concept of making a query go faster by creating indexes, but it seems that when I want data from multiple tables that link together the query goes slow. The slow is typically due to expensive nested loops. The reason is, all my brain understands is:

select
tablea.data
tableb.data
tablec.data
from
tablea
tableb
tablec
where
tablea.pri_key = tableb.foreign_key AND
tableb.pri_key = tablec.foreign_key AND...

From what I read, it seems you can use inner/outer right/left join on (bla) but when I see syntax examples I see that sometimes tables are omitted from the 'from' section of the query and other times, no. Sometimes I see that the join commands are nested and others, no and sometimes I see joins syntax that only applies to one table. From what I understand join can be used to tell the database the fast way to murge table data together to get results by specifiying the table that has the primary keys and the table that has the foreign keys.

I've read all through the postgres docs on this command and I'm still left lost. Can someone please explain to me in simple language how to use these commands or provide me with a link. I need it to live right now. Thanx.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig A. James 2006-01-26 16:12:45 Re: Query optimization with X Y JOIN
Previous Message John D. Burger 2006-01-26 15:13:52 Re: pgstattuple output?

Browse pgsql-performance by date

  From Date Subject
Next Message Jozsef Szalay 2006-01-26 15:50:29 Incorrect Total runtime Reported by Explain Analyze!?
Previous Message Jignesh K. Shah 2006-01-26 14:56:14 Re: PostgreSQL Solaris packages now in beta

Browse pgsql-sql by date

  From Date Subject
Next Message Craig A. James 2006-01-26 16:12:45 Re: Query optimization with X Y JOIN
Previous Message Stephan Szabo 2006-01-26 15:28:56 Re: Changing the transaction isolation level within the stored