Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 97B6F133740B for ; Sun, 10 Apr 2011 23:41:08 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 52443-10 for ; Mon, 11 Apr 2011 02:41:01 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.9]) by mail.postgresql.org (Postfix) with ESMTP id D2D05133616B for ; Sun, 10 Apr 2011 23:39:45 -0300 (ADT) Received: from [192.168.1.6] (mail.highperformancepostgresql.com [71.179.240.8]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0MSrBt-1QJBdE3MH7-00RpgW; Mon, 11 Apr 2011 04:39:46 +0200 Message-ID: <4DA26A30.6010208@2ndQuadrant.com> Date: Sun, 10 Apr 2011 22:40:48 -0400 From: Greg Smith User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110307 Icedove/3.0.11 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: optimizer parameters References: <77760.3733.qm@web38606.mail.mud.yahoo.com> <4DA23CFE.7020109@fuzzy.cz> In-Reply-To: <4DA23CFE.7020109@fuzzy.cz> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:b7JKGZUsjjqNjBhRvXAbtmHB2Ecq/inFPMseapXqz+C 0z1lbFLwn8J5zfiVbC0oQ2aZLtgzpBE5LJAg8KB3vy8SDHEN7Y VaPFq+CeoEbq42dF2Jnwl3+qXVJq3Ijckhs3qtf0ZKY7m+wE5R Jn8eDLNowD13pWORanIC/dcRoGLvvPQFPRJ8LJPgv8HD0D+SeE 9uBxTJ9tJn/uFC08sjVDi1GY7iJrQZUZBUedKTmFoc= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201104/100 X-Sequence-Number: 43162 On 04/10/2011 07:27 PM, Tomas Vondra wrote: > But if you need more details, then I quess the best approach to get it > is to read the sources (search for the cost estimation etc.). > There's a small fully worked out example of this in my book too, where I duplicate the optimizer's EXPLAIN cost computations for a simple query. The main subtle thing most people don't appreciate fully is how much the optimizer takes into account two things: the selectivity of operators, and the expected size of the data being moved around. For example, a lot of the confusion around "why didn't it use my index?" comes from not noticing the size of the index involved, and therefore how expensive its page cost is considered to be. -- Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us "PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books