Re: [PERFORM] Strange plan in pg 8.1.0

2006-10-30 Thread Steinar H. Gunderson
On Mon, Oct 30, 2006 at 03:26:09PM +0100, Mattias Kregert wrote: > On the left side it is text, and on the right side it is varchar(10). > Casting left side to varchar(10) does not help, in fact it makes things > even worse: The cast to ::text vanishes in a puff of logic, but the plan > gets bigg

Re: [PERFORM] Strange plan in pg 8.1.0

2006-10-30 Thread Mattias Kregert
From: "Tom Lane" <[EMAIL PROTECTED]> Mattias Kregert <[EMAIL PROTECTED]> writes: Why does it come up with this strange plan? Because 8.1 can't reorder outer joins. To devise the plan you want, the planner has to be able to prove that it's OK to perform the IN join before the LEFT join, someth

Re: [PERFORM] Strange plan in pg 8.1.0

2006-10-30 Thread Tom Lane
Mattias Kregert <[EMAIL PROTECTED]> writes: > Why does it come up with this strange plan? Because 8.1 can't reorder outer joins. To devise the plan you want, the planner has to be able to prove that it's OK to perform the IN join before the LEFT join, something that isn't always the case. 8.2 ca

Re: [PERFORM] Strange plan in pg 8.1.0

2006-10-30 Thread Mattias Kregert
From: "Steinar H. Gunderson" <[EMAIL PROTECTED]> On Mon, Oct 30, 2006 at 01:05:07PM +0200, Mattias Kregert wrote: -> Hash Left Join (cost=59.66..206763.11 rows=1215336 width=27) (actual time=4.959..3228.550 rows=1216434 loops=1) Hash Cond: (("outer".prislista = ("inner"

Re: [PERFORM] Strange plan in pg 8.1.0

2006-10-30 Thread Steinar H. Gunderson
On Mon, Oct 30, 2006 at 01:05:07PM +0200, Mattias Kregert wrote: > -> Hash Left Join (cost=59.66..206763.11 rows=1215336 width=27) > (actual time=4.959..3228.550 rows=1216434 loops=1) >Hash Cond: (("outer".prislista = ("inner".listid)::text) AND > ("outer".tjanst = ("in

[PERFORM] Strange plan in pg 8.1.0

2006-10-30 Thread Mattias Kregert
Look at this insane plan: lucas=# explain analyse select huvudklass,sum(summa) from kor_tjanster left outer join prislist on prislista=listid and tjanst=tjanstid where kor_id in (select id from kor where lista=10484) group by 1; QU