Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TGy76-0006Ve-HK; Wed, 26 Sep 2012 20:21:44 +0000 Received: from andy.depesz.com ([88.198.47.100] helo=depesz.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TGy74-0007o2-Pk; Wed, 26 Sep 2012 20:21:44 +0000 Received: from andy.depesz.com ([88.198.47.100] helo=depesz.com) by depesz.com with esmtpa (Exim 4.80) (envelope-from ) id 1TGy72-0003ut-SN; Wed, 26 Sep 2012 22:21:41 +0200 Date: Wed, 26 Sep 2012 22:21:40 +0200 From: hubert depesz lubaczewski To: Robert Sosinski Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org, Spike Grobstein Subject: Re: Inaccurate Explain Cost Message-ID: <20120926202140.GB10681@depesz.com> Reply-To: depesz@depesz.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -2.7 (--) X-Archive-Number: 201209/145 X-Sequence-Number: 47891 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? If yes - that's not true, and afaik never was. the fact that you got similar time and cost is just a coincidence. Best regards, depesz -- The best thing about modern society is how easy it is to avoid contact with it. http://depesz.com/