[GENERAL] performance advice needed: join vs explicit subselect

2009-01-27 Thread Karsten Hilbert
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

Re: [GENERAL] performance advice needed: join vs explicit subselect

2009-01-27 Thread justin
Karsten Hilbert wrote: 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

Re: [GENERAL] performance advice needed: join vs explicit subselect

2009-01-27 Thread justin
typo sorry justin wrote: Karsten Hilbert wrote: 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

Re: [GENERAL] performance advice needed: join vs explicit subselect

2009-01-27 Thread Sam Mason
On Tue, Jan 27, 2009 at 07:12:05PM +0100, Karsten Hilbert wrote: 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

Re: [GENERAL] performance advice needed: join vs explicit subselect

2009-01-27 Thread Alban Hertroys
On Jan 27, 2009, at 7:12 PM, Karsten Hilbert wrote: 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)

Re: [GENERAL] performance advice needed: join vs explicit subselect

2009-01-27 Thread Karsten Hilbert
On Tue, Jan 27, 2009 at 06:48:11PM +, Sam Mason wrote: 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

Re: [GENERAL] performance advice needed: join vs explicit subselect

2009-01-27 Thread Tom Lane
Karsten Hilbert karsten.hilb...@gmx.net writes: The view in question is in fact a lot more complicated. This is the best I've been able to come up with so far (and it is still slow - slow as in 3-4 seconds for 20 records out of (currently only) 50 !): What does EXPLAIN ANALYZE say about it?

Re: [GENERAL] performance advice needed: join vs explicit subselect

2009-01-27 Thread Karsten Hilbert
On Tue, Jan 27, 2009 at 04:42:02PM -0500, Tom Lane wrote: Karsten Hilbert karsten.hilb...@gmx.net writes: The view in question is in fact a lot more complicated. This is the best I've been able to come up with so far (and it is still slow - slow as in 3-4 seconds for 20 records out of

Re: [GENERAL] performance advice needed: join vs explicit subselect

2009-01-27 Thread Karsten Hilbert
On Tue, Jan 27, 2009 at 04:42:02PM -0500, Tom Lane wrote: What does EXPLAIN ANALYZE say about it? Also, what is the use-case you are concerned about --- selecting the whole view contents, or selecting WHERE something-or-other? Oh, and the use case is to select all the test_results which

Re: [GENERAL] performance advice needed: join vs explicit subselect

2009-01-27 Thread Tom Lane
Karsten Hilbert karsten.hilb...@gmx.net writes: the explain analyze of which is (I've actually gotten it to work better in the meantime as you can see): Looks like most of the problem is in the subquery scans on v_staff, which seems to be a rather expensive view :-(. Maybe you can simplify

Re: [GENERAL] performance advice needed: join vs explicit subselect

2009-01-27 Thread Karsten Hilbert
On Tue, Jan 27, 2009 at 05:30:23PM -0500, Tom Lane wrote: Karsten Hilbert karsten.hilb...@gmx.net writes: the explain analyze of which is (I've actually gotten it to work better in the meantime as you can see): Looks like most of the problem is in the subquery scans on v_staff, which