explain analyse and nested loop joins

From: Oliver Kohll - Mailing Lists <oliver(dot)lists(at)gtwm(dot)co(dot)uk>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: explain analyse and nested loop joins
Date: 2011-11-05 19:21:23
Message-ID: 8690371E-0791-48D8-804F-1296215A6B31@gtwm.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have a query I'm trying to optimise. It takes just under a second to run, not too bad for my users but I'm worried that as the size of the data increases, it will get worse. Of course the plan may change when that happens but I'd also like to learn a bit more about optimisation anyway.

The explain is here:

http://explain.depesz.com/s/Ost

- that one took 690ms. Seeing it had a couple of nested joins at the top, I 'set enable_nestloop = false;', resulting in an improvement of about 20x:

http://explain.depesz.com/s/BRi

The query is below. It joins to a second report dbvcalc_delivery_charges which I can also send if necessary. I've only guesses as to the reasons the default plan is slow or how to affect it, can someone enlighten me?

Regards
Oliver Kohll
www.agilebase.co.uk

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tair Sabirgaliev 2011-11-05 19:21:56 Re: What is *wrong* with this query???
Previous Message Rodrigo Gonzalez 2011-11-05 19:17:13 Re: What is *wrong* with this query???