Re: [GENERAL] View with an outer join - is there any way to optimise

2005-12-13 Thread Rich Doughty
Tom Lane wrote: Rich Doughty <[EMAIL PROTECTED]> writes: I have a view vw_tokens defined as ... I cannot however perform a meaningful join against this view. ... PG forms the full output of the view. You seem to be wishing that PG would push the INNER JOIN down inside the nested LEFT JOINs.

Re: [GENERAL] View with an outer join - is there any way to optimise this?

2005-12-12 Thread Tom Lane
Rich Doughty <[EMAIL PROTECTED]> writes: > I have a view vw_tokens defined as > ... > I cannot however perform a meaningful join against this view. > ... > PG forms the full output of the view. You seem to be wishing that PG would push the INNER JOIN down inside the nested LEFT JOINs. In general,

Re: [GENERAL] View with an outer join - is there any way to optimise

2005-12-12 Thread Rich Doughty
John McCawley wrote: You should be able to use my trick...the join that is giving you the problem is: SELECT * FROM tokens.ta_tokenhist h INNER JOIN tokens.vw_tokenst ON h.token_id = t.token_id WHERE h.sarreport_id = 9 ; ta_tokenhist is already part of your view, right?

Re: [GENERAL] View with an outer join - is there any way to optimise

2005-12-12 Thread John McCawley
You should be able to use my trick...the join that is giving you the problem is: SELECT * FROM tokens.ta_tokenhist h INNER JOIN tokens.vw_tokenst ON h.token_id = t.token_id WHERE h.sarreport_id = 9 ; ta_tokenhist is already part of your view, right? So you should be able

Re: [GENERAL] View with an outer join - is there any way to optimise

2005-12-12 Thread John McCawley
First of all, check out this thread: http://archives.postgresql.org/pgsql-general/2005-11/msg00734.php I had a similar performance issue with a view. Look at my solution and it might help you out. Second, you might want to change your token history status from a string to an integer that re

Re: [GENERAL] View with an outer join - is there any way to optimise

2005-12-12 Thread Rich Doughty
John McCawley wrote: First of all, check out this thread: http://archives.postgresql.org/pgsql-general/2005-11/msg00734.php I had a similar performance issue with a view. Look at my solution and it might help you out. i'm not sure that'll help in my case as ta_tokens has a 1-to-many relatio

[GENERAL] View with an outer join - is there any way to optimise this?

2005-12-12 Thread Rich Doughty
I have a view vw_tokens defined as CREATE VIEW tokens.vw_tokens AS SELECT -- too many columns to mention FROM tokens.ta_tokens t LEFT JOIN tokens.ta_tokenhist i ON t.token_id = i.token_id AND i.status = 'issued' LEFT JOIN