Re: [PERFORM] Outer join query plans and performance

2005-10-26 Thread Rich Doughty
Tom Lane wrote: Rich Doughty <[EMAIL PROTECTED]> writes: Tom Lane wrote: The reason these are different is that the second case constrains only the last-to-be-joined table, so the full cartesian product of t and h1 has to be formed. If this wasn't what you had in mind, you might be able to r

Re: [PERFORM] Outer join query plans and performance

2005-10-25 Thread Kevin Grittner
In this particular case both outer joins are to the same table, and the where clause is applied to one or the other, so it's pretty easy to prove that they should generate identical results. I'll grant that this is not generally very useful; but then, simple test cases often don't look very useful

Re: [PERFORM] Outer join query plans and performance

2005-10-25 Thread Tom Lane
Rich Doughty <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> The reason these are different is that the second case constrains only >> the last-to-be-joined table, so the full cartesian product of t and h1 >> has to be formed. If this wasn't what you had in mind, you might be >> able to rearrange

Re: [PERFORM] Outer join query plans and performance

2005-10-25 Thread Rich Doughty
Tom Lane wrote: Rich Doughty <[EMAIL PROTECTED]> writes: EXPLAIN SELECT * FROM tokens.ta_tokens t LEFT JOIN tokens.ta_tokenhist h1 ON t.token_id = h1.token_id LEFT JOIN tokens.ta_tokenhist h2 ON t.token_id = h2.token_id WHERE h1.histdate = 'now'; EXPLAIN SELECT * F

Re: [PERFORM] Outer join query plans and performance

2005-10-25 Thread Tom Lane
Rich Doughty <[EMAIL PROTECTED]> writes: > EXPLAIN SELECT * > FROM > tokens.ta_tokens t LEFT JOIN > tokens.ta_tokenhist h1 ON t.token_id = h1.token_id LEFT JOIN > tokens.ta_tokenhist h2 ON t.token_id = h2.token_id > WHERE > h1.histdate = 'now'; > EXPLAIN SELECT * > FR

[PERFORM] Outer join query plans and performance

2005-10-25 Thread Rich Doughty
I tried on pgsql-general but got no reply. re-posting here as it's probably the best place to ask I'm having some significant performance problems with left join. Can anyone give me any pointers as to why the following 2 query plans are so different? EXPLAIN SELECT * FROM tokens.ta_tokens