Re: join syntax

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: join syntax
Дата
Msg-id 200306171148.09162.josh@agliodbs.com
обсуждение исходный текст
Ответ на join syntax  (Jodi Kanter <jkanter@virginia.edu>)
Список 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 по дате отправления:

Предыдущее
От:
Дата:
Сообщение: Re: disabling triggers
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: disabling triggers