Re: [GENERAL] Inaccurate Explain Cost

From: Matthias <nitrogenycs(at)gmail(dot)com>
To: depesz(at)depesz(dot)com, "Jeff Janes" <jeff(dot)janes(at)gmail(dot)com>
Cc: "Robert Sosinski" <rsosinski(at)ticketevolution(dot)com>, pgsql-general(at)postgresql(dot)org, pgsql-performance(at)postgresql(dot)org, "Spike Grobstein" <spike(at)ticketevolution(dot)com>
Subject: Re: [GENERAL] Inaccurate Explain Cost
Date: 2012-09-27 10:48:24
Message-ID: op.wlaiyyw50uf2nk@nitrogenycs3
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

Am 27.09.2012, 02:04 Uhr, schrieb Jeff Janes <jeff(dot)janes(at)gmail(dot)com>:

> On Wed, Sep 26, 2012 at 1:21 PM, hubert depesz lubaczewski
> <depesz(at)depesz(dot)com> wrote:
>> On Wed, Sep 26, 2012 at 02:38:09PM -0400, Robert Sosinski wrote:
>>> The first query shows a cost of 190,169.55 and runs in 199,806.951 ms.
>>> When I disable nested loop, I get a cost of 2,535,992.34 which runs in
>>> only 133,447.790 ms. We have run queries on our database with a cost
>>> of 200K cost before and they ran less then a few seconds, which makes
>>> me wonder if the first query plan is inaccurate. The other issue is
>>> understanding why a query plan with a much higher cost is taking less
>>> time to run.
>>
>> Are you under impression that cost should be somehow related to actual
>> time?
>
> I am certainly under that impression. If the estimated cost has
> nothing to do with run time, then what is it that the cost-based
> optimizer is trying to optimize?

See http://www.postgresql.org/docs/9.2/static/runtime-config-query.html
section "18.7.2. Planner Cost Constants".

-Matthias

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2012-09-27 10:51:16 Re: unc paths, like and backslashes on 8.4
Previous Message Albe Laurenz 2012-09-27 10:39:15 Re: Re: Need help in reclaiming disk space by deleting the selected records

Browse pgsql-performance by date

  From Date Subject
Next Message M. D. 2012-09-27 19:11:24 hardware advice
Previous Message Undertaker Rude 2012-09-27 09:01:48 Re: Same query doing slow then quick