Re: [GENERAL] JOIN issues (Left vs Right for sorting), and "Nested Loop" problem

2007-09-01 Thread Tom Lane
Alban Hertroys <[EMAIL PROTECTED]> writes: > I am kind of surprised that the planner doesn't understand that a > foreign key with a unique constraint (which a primary key is) means > there is a 0..1 to 1 relationship with the target table. Hm? It correctly estimated that it'd get one row out

Re: [GENERAL] JOIN issues (Left vs Right for sorting), and "Nested Loop" problem

2007-09-01 Thread Tom Lane
"Phoenix Kiula" <[EMAIL PROTECTED]> writes: > On 01/09/07, Alban Hertroys <[EMAIL PROTECTED]> wrote: >> Is 10 ms problematic for this query? > I think you got 10ms from the query plan? These queries are very fast > after they have been executed once. But the first time is huge. > Sometimes I have

Re: [GENERAL] JOIN issues (Left vs Right for sorting), and "Nested Loop" problem

2007-09-01 Thread Alban Hertroys
On Sep 1, 2007, at 14:48, Phoenix Kiula wrote: On 01/09/07, Alban Hertroys <[EMAIL PROTECTED]> wrote: On Sep 1, 2007, at 11:46, Phoenix Kiula wrote: . ..snip However, there's a nested loop in there as the EXPLAIN ANALYZE shows below. What is causing this nested loop? It looks like it

Re: [GENERAL] JOIN issues (Left vs Right for sorting), and "Nested Loop" problem

2007-09-01 Thread Phoenix Kiula
On 01/09/07, Alban Hertroys <[EMAIL PROTECTED]> wrote: > > On Sep 1, 2007, at 11:46, Phoenix Kiula wrote: . ..snip > > However, there's a nested loop in there as the EXPLAIN ANALYZE shows > > below. What is causing this nested loop? > > It looks like it's used to match trades to tradecounts. I

Re: [GENERAL] JOIN issues (Left vs Right for sorting), and "Nested Loop" problem

2007-09-01 Thread Alban Hertroys
On Sep 1, 2007, at 11:46, Phoenix Kiula wrote: Hello, I have a simple query as follows. It joins two very straightforward tables. SELECT trades.id, trades.url, trades.alias, tradecount.t_count, tradecount.u_count FROM trades LEFT JOIN tradecount ON trades.id = tradecount.id WHER

[GENERAL] JOIN issues (Left vs Right for sorting), and "Nested Loop" problem

2007-09-01 Thread Phoenix Kiula
Hello, I have a simple query as follows. It joins two very straightforward tables. SELECT trades.id, trades.url, trades.alias, tradecount.t_count, tradecount.u_count FROM trades LEFT JOIN tradecount ON trades.id = tradecount.id WHERE trades.user_id = 'jondoe' and trades.status = 'Y' OR

Re: [GENERAL] Join Issues

2003-12-16 Thread Stephan Szabo
On Tue, 16 Dec 2003, Dev wrote: > Hello all, > > I have been working with joins and having alot of success up until now. > > What I have is this: > SELECT a.merno > ,g.mcmid > FROM ( >total AS a LEFT JOIN mcmid AS g ON (g.merno=a.merno)) > WHERE a.repno='11' > AND a.month='2003-11-

[GENERAL] Join Issues

2003-12-16 Thread Dev
Hello all, I have been working with joins and having alot of success up until now. What I have is this: SELECT a.merno ,g.mcmid FROM ( total AS a LEFT JOIN mcmid AS g ON (g.merno=a.merno)) WHERE a.repno='11' AND a.month='2003-11-01' AND g.month='2003-11-01' ORDER BY merno Currently it