pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig A. James <cjames@modgraph-usa.com>
To: pgsql-performance@postgresql.org
Subject: Re: Query optimization with X Y JOIN
Date: Thu, 26 Jan 2006 08:12:45 -0800
Message-ID: <43D8F4FD.4040703@modgraph-usa.com> (raw)
In-Reply-To: <005d01c6228f$3772dca0$0d310d05@fatchubby>
References: <786c2f6d0601260206k2201a548p48af7c7fc085d3b2@mail.gmail.com>
	<005d01c6228f$3772dca0$0d310d05@fatchubby>

First, this isn't really the right place to ask -- this forum is about performance, not SQL syntax.

Second, this isn't a question anyone can answer in a reasonable length of time.  What you're asking for usually is taught in a class on relational database theory, which is typically a semester or two in college.

If you really need a crash course, dig around on the web for terms like "SQL Tutorial".

Good luck,
Craig


J@Planeti.Biz wrote:
> 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.
>  
>    



view thread (7+ messages)  latest in thread

Message-ID: <43D8F4FD.4040703@modgraph-usa.com>
Permalink:  ../43D8F4FD.4040703@modgraph-usa.com/
Also on:    postgresql.org/message-id/43D8F4FD.4040703@modgraph-usa.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: cjames@modgraph-usa.com, pgsql-performance@postgresql.org
  Subject: Re: Query optimization with X Y JOIN
  In-Reply-To: <43D8F4FD.4040703@modgraph-usa.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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