Is disableing nested_loops a bad idea ?

From: Franck Routier <franck(dot)routier(at)axege(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Is disableing nested_loops a bad idea ?
Date: 2010-09-16 08:23:47
Message-ID: 1284625427.2527.13.camel@franck-laptop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi,

I am confronted with a use case where my database mainly does big
aggregate select (ROLAP), a bunch of batch jobs, and quite few OLTP.

I come into cases where the planner under-estimates the number of rows
in some relations, chooses to go for nested loops, and takes forever to
complete the request. (Notice as the side note that Oracle (10g or 11g)
is not any better on this workload and will sometime go crazy and choose
a plan that takes hours...)

I've played with statistics, vacuum and so on, but at the end the
planner is not accurate enough when evaluating the number of rows in
some complex queries.

Disableing nested loops most of the time solves the performance issues
in my tests... generally going from 30 sec. down to 1 sec.

So my question is : would it be a very bad idea to disable nested loops
in production ?
The way I see it is that it could be a little bit less optimal to use
merge join or hash join when joining on a few rows, but this is peanuts
compared to how bad it is to use nested loops when the number of rows
happens to be much higher than what the planner thinks.

Is this stupid, ie are there cases when merge join or hash join are much
slower than nested loops on a few rows ?

Thanks in advance,

Franck

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Samuel Gendler 2010-09-16 09:55:55 Re: Is disableing nested_loops a bad idea ?
Previous Message Anssi Kääriäinen 2010-09-16 05:51:19 Re: Performance problem with joined aggregate query