Join questions - Mailing list pgsql-general

From Bruno Wolff III
Subject Join questions
Date
Msg-id 20010822100839.A13537@wolff.to
Whole thread Raw
Responses Re: Join questions
List pgsql-general
I have two related questions about joins.

One is that if you don't group with parenthesis, what order are they
done in?

Will the optimizer be able to pick the better order of the two possible
orders in the following example or do I need to try both and pick one?

select accerate, colodesc, editcode from
  (acce natural join colo) natural left join edit;

select accerate, colodesc, editcode from
  (acce natural left join edit) natural join colo;

The above are equivalent because there is exactly one colo record that will
match up with each acce record. (The table definitions are below.)

create table colo (
  colocode serial primary key,
  colodesc text unique not null
    constraint bad_colodesc check (colodesc ~ '^[\041-\176]+( [\041-\176]+)*$'),
  colonote text
    constraint bad_colonote check (colonote ~ '^[\041-\176]+( [\041-\176]+)*$')
);

create table acce (
  accecode serial primary key,
  accerate numeric(2,1) unique not null,
  colocode int4 not null
    constraint bad_colocode references colo,
  accenote text
    constraint bad_accenote check (accenote ~ '^[\041-\176]+( [\041-\176]+)*$')
);

create table edit (
  editcode serial primary key,
  titlcode int4 not null
    constraint bad_titlcode references titl,
  langcode int4 not null
    constraint bad_langcode references lang,
  accecode int4
    constraint bad_accecode references acce,
  editnote text
    constraint bad_editnote check (editnote ~ '^[\041-\176]+( [\041-\176]+)*$')
);

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: problems transfering databases
Next
From: Andrew Gould
Date:
Subject: During dump: function not found