performance advice needed: join vs explicit subselect - Mailing list pgsql-general

From Karsten Hilbert
Subject performance advice needed: join vs explicit subselect
Date
Msg-id 20090127181205.GA3820@merkur.hilbert.loc
Whole thread Raw
Responses Re: performance advice needed: join vs explicit subselect
Re: performance advice needed: join vs explicit subselect
Re: performance advice needed: join vs explicit subselect
List pgsql-general
Hello all,

maybe some general advice can be had on this:

table test_results
    modified_by integer foreign key staff(pk),
    intended_reviewer integer foreign key staff(pk),
    actual_reviewer integer foreign key staff(pk)

(this table will contain millions of rows)

table staff
    pk integer
    name text

(this table will contain at most 50 rows)

Now I want to set up a view which aggregates test results
with staff names for all three foreign keys. This would mean
I would either have to

- join test_results to staff three times, once for each
  of the foreign keys, this is going to be messy with
  tracking table aliases, duplicate column names etc

- write three explicit sub-selects for the columns I want
  to denormalize into the view definition

Is there general advice as to which of the alternatives is
worse under most if not all circumstances ?

Thanks,
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

pgsql-general by date:

Previous
From: Jeff Davis
Date:
Subject: Re: New 8.4 hot standby feature
Next
From: Sam Mason
Date:
Subject: Re: FW: information about tables via psql