Re: SV: bad plan using nested loops

2018-02-05 Thread Tomas Vondra
On 02/02/2018 10:02 AM, Johan Fredriksson wrote: > tor 2018-02-01 klockan 20:34 + skrev Johan Fredriksson: >>> Johan Fredriksson writes: Bad plan: https://explain.depesz.com/s/avtZ Good plan: https://explain.depesz.com/s/SJSt Any suggestions on how to make the planner make bet

Re: SV: bad plan using nested loops

2018-02-02 Thread Johan Fredriksson
tor 2018-02-01 klockan 20:34 + skrev Johan Fredriksson: > > Johan Fredriksson writes: > > > Bad plan: https://explain.depesz.com/s/avtZ > > > Good plan: https://explain.depesz.com/s/SJSt > > > Any suggestions on how to make the planner make better decisions > > > for > > > this query? > > > >

SV: bad plan using nested loops

2018-02-01 Thread Johan Fredriksson
> Johan Fredriksson writes: > > Bad plan: https://explain.depesz.com/s/avtZ > > Good plan: https://explain.depesz.com/s/SJSt > > Any suggestions on how to make the planner make better decisions for > > this query? > > Core of the problem looks to be the misestimation here: > >Index Only

Re: bad plan using nested loops

2018-02-01 Thread Tom Lane
Johan Fredriksson writes: > Bad plan: https://explain.depesz.com/s/avtZ > Good plan: https://explain.depesz.com/s/SJSt > Any suggestions on how to make the planner make better decisions for > this query? Core of the problem looks to be the misestimation here: Index Only Scan using shredd

bad plan using nested loops

2018-02-01 Thread Johan Fredriksson
Hello! I brought this issue up about two years ago but without getting any real explanation or solution. The problem is that PostgreSQL does really bad plans using nested loops. With "enable_nestloop = 0" the same query is run about 20 times faster. The sugested solution I got back then was to up