Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1THBdz-0001Ar-SL; Thu, 27 Sep 2012 10:48:36 +0000 Received: from mail-wi0-f178.google.com ([209.85.212.178]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1THBdx-0005mk-LI; Thu, 27 Sep 2012 10:48:34 +0000 Received: by wibhr7 with SMTP id hr7so1832282wib.1 for ; Thu, 27 Sep 2012 03:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:to:cc:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=xIgWzRZoJ+qcEDGdPwaNQVsOgQYC5YiCiXD25Nye5tE=; b=JHIfEKc7Cy948mYChzNEhvJ9SEntTD3PA6jjzx6FKB3qbHx5DpUAZ7WBZqsCe/V/Tg b+i0etnS3ULC9aIbT5hlm2un9TfK85dHL0DBVL9dP3qZIaLWneXejKmS699wet5vD07J 1qxpe3h9QyYOtJM+tv/aUVGR5bgxo9TOvM8bO825nNkuVahuGgGhY0ZVT/Z9tGt1AK7n PE9PU3p73LeaXCOPPgiEZtroPrYIS29STuMOqDnR4ap2taI4+hc8Tersu7GOKHkSD2HS SYF2Lkl8Mkp9UZraJ0s7cMzMJ6jcLeZgD7Xx2W1wK2mCF+/3jUtPfgUMxqp+fEKap/ZJ 4Gzg== Received: by 10.180.100.35 with SMTP id ev3mr35853519wib.7.1348742911693; Thu, 27 Sep 2012 03:48:31 -0700 (PDT) Received: from nitrogenycs3 (p5089B896.dip.t-dialin.net. [80.137.184.150]) by mx.google.com with ESMTPS id hv8sm37408679wib.0.2012.09.27.03.48.29 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 03:48:30 -0700 (PDT) Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: depesz@depesz.com, "Jeff Janes" Cc: "Robert Sosinski" , pgsql-general@postgresql.org, pgsql-performance@postgresql.org, "Spike Grobstein" Subject: Re: [GENERAL] Inaccurate Explain Cost References: <20120926202140.GB10681@depesz.com> Date: Thu, 27 Sep 2012 12:48:24 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Matthias Message-ID: In-Reply-To: User-Agent: Opera Mail/12.02 (Win32) X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201209/212 X-Sequence-Number: 47958 Am 27.09.2012, 02:04 Uhr, schrieb Jeff Janes : > On Wed, Sep 26, 2012 at 1:21 PM, hubert depesz lubaczewski > 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