NATURAL JOINs - Mailing list pgsql-general

From Reg Me Please
Subject NATURAL JOINs
Date
Msg-id 200810131852.57897.regmeplease@gmail.com
Whole thread Raw
Responses Re: NATURAL JOINs  ("Richard Broersma" <richard.broersma@gmail.com>)
List pgsql-general
Hi all.

I'm running v8.3.3

First point.
Is there a way to know how a NATURAL JOIN is actually done?
That is, which fields are actually used for the join?
The EXPLAIN directive doesn't show anyting useful.

Second point.
I have this:

CREATE TABLE tab_dictionary ( item text primary key );

CREATE TABLE tab_atable(
  item1 TEXT NOT NULL REFERENCES tab_dictionary( item ),
  item2 TEXT NOT NULL REFERENCES tab_dictionary( item ),
  trans NUMERIC NOT NULL
);

INSERT INTO tab_dictionary VALUES ( 'meters' ),('feet' );

INSERT INTO tab_atable VALUES ( 'meters','feet',3.28084 );

SELECT * FROM tab_atable NATURAL JOIN tab_dictionary;
 item1  | item2 |  trans  |  item
--------+-------+---------+--------
 meters | feet  | 3.28084 | meters
 meters | feet  | 3.28084 | feet
(2 rows)

Very likely I'm wrong, but this output looks wrong to me (and shold be wrong
also accordingly to the documentation).
Is there ant good explaination to this behaviour?

Thanks.


pgsql-general by date:

Previous
From: Matthew Wilson
Date:
Subject: More schema design advice requested
Next
From: "Richard Broersma"
Date:
Subject: Re: NATURAL JOINs