Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 4B7621337B96 for ; Fri, 25 Mar 2011 11:41:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 48457-08 for ; Fri, 25 Mar 2011 14:40:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id 4D3051337B49 for ; Fri, 25 Mar 2011 11:40:51 -0300 (ADT) Received: by fxm17 with SMTP id 17so1200425fxm.19 for ; Fri, 25 Mar 2011 07:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=IXkAw58rkGzSr1hfpdFh3CrzzPel18HiWsP1jq3AWgs=; b=uJ20m8KZnY8q9vNRjfibMWOKpPFUfJSY2vINSCPW7O7bs6F/QpgQVIgbSVoLRPuNBD OgpClzgH2ILynB9Gg5V78SjBb+um+lmpkRuHj0lEvPkcVeByHSXJ6Q+QtjC091bF1gM3 2lbFzq6E/JQ82DIIp3sv2N6gWP7QT2HPIGBF4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=t78qWz7eU1fEDGQpO5fo5suUti9sHxZF14QyousodtGA/0Y1t4tRH7gFFmbQAz2mi/ 9T46hWn/HQD86NyZ8mtDqbt5YVzM7fwH5tq3DrPv0cb30tNfLudK7KfqR+Mmuv0ouup0 50LlA6/Jtj5+jOuQUj2n41tUG5wn4jsWZ1Uz4= Received: by 10.223.110.21 with SMTP id l21mr987077fap.70.1301064050898; Fri, 25 Mar 2011 07:40:50 -0700 (PDT) Received: from [10.1.1.57] (skuns.zoral.com.ua [91.193.166.194]) by mx.google.com with ESMTPS id b18sm449345fak.32.2011.03.25.07.40.48 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Mar 2011 07:40:49 -0700 (PDT) Message-ID: <4D8CA989.2080904@gmail.com> Date: Fri, 25 Mar 2011 16:41:13 +0200 From: Vitalii Tymchyshyn User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: Tom Lane CC: Merlin Moncure , Claudio Freire , Josh Berkus , postgres performance list Subject: Re: Shouldn't we have a way to avoid "risky" plans? References: <4D8A29F2.9080105@agliodbs.com> <4D8A581D.5080704@agliodbs.com> <4286.1300914004@sss.pgh.pa.us> <4D8C63B2.1060800@gmail.com> <2951.1301062330@sss.pgh.pa.us> In-Reply-To: <2951.1301062330@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.346 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001 X-Spam-Level: X-Archive-Number: 201103/336 X-Sequence-Number: 43015 25.03.11 16:12, Tom Lane написав(ла): > Vitalii Tymchyshyn writes: > >> Why so? I simply change cost estimation functions. This won't change >> number of pathes. > If you have multiple figures of merit, that means you have to keep more > paths, with consequent slowdown when it comes to choosing which path to > use at higher join levels. > > As an example, we used to keep only the paths with best total cost. > When we started to optimize LIMIT, we had to keep around paths with best > startup cost too, in case that made for the best combined result at a > higher join level. If you're going to consider "risk" while choosing > paths, that means you'll start keeping paths you would have discarded > before, while not necessarily getting rid of any other paths. The only > way to avoid that would be to have a completely brain-dead notion of > risk that wasn't affected by how the path is used at a higher join > level, and I'm pretty sure that that wouldn't solve anybody's problem. > > Any significant expansion of the planner's fundamental cost model *will* > make it slower. By a lot. Rather than going into this with fantasies > of "it won't cost anything", you should be worrying about how to keep > the speed penalty to factor-of-two rather than factor-of-ten. But I am not talking about model change, it's more like formula change. Introducing limit added one variable where outer plan could influence inner plan selection. But I am talking simply about cost calculation for given node. Now cost is based on statistical expected value, the proposal is (something like) to take maximum cost on n% probability range near expected value. This, of course, will make calculations slower, but won't add any degree of freedom to calculations. Best regards, Vitalii Tymchyshyn