Re: join syntax - Mailing list pgsql-sql

From Josh Berkus
Subject Re: join syntax
Date
Msg-id 200306171148.09162.josh@agliodbs.com
Whole thread Raw
In response to join syntax  (Jodi Kanter <jkanter@virginia.edu>)
List pgsql-sql
Jodi,

> One of my colleagues has created a database where he has the same field
> name in two tables and uses this field to link his tables rather than
> some arbitrary value. For example, he has used "exp_id" in two tables.
> When writing his joins he uses a syntax that says something like JOIN ON
> EXP_ID. Can someone tell me what that syntax should be? I am not very
> familiar with it since I typically use the syntax where one field is set
> equal to the other.

table_a JOIN table_b USING (exp_id)

> Personally I prefer not to set databases up this way but cannot seem to
> convince him of this. And yet I am supposed to now help him with his
> database and application..

That, we can't help you with.

Point out to your friend, though, that an explicit JOIN order can often harm
performance when the JOIN order given by the query writer is not ideal.  That
is, the "FROM table, table, table WHERE expression, expression" syntax gives
the parser a freer hand to choose the fastest execution method.  Of course,
on a very small database that typically makes litte difference.

--
-Josh BerkusAglio Database SolutionsSan Francisco



pgsql-sql by date:

Previous
From:
Date:
Subject: Re: disabling triggers
Next
From: Josh Berkus
Date:
Subject: Re: disabling triggers