Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VJrfM-0005tx-3e for pgsql-performance@arkaria.postgresql.org; Wed, 11 Sep 2013 21:09:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VJrfL-00054I-88 for pgsql-performance@arkaria.postgresql.org; Wed, 11 Sep 2013 21:09:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VJrfJ-000549-U8 for pgsql-performance@postgresql.org; Wed, 11 Sep 2013 21:09:33 +0000 Received: from mbx.knossos.net.nz ([202.160.48.10]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VJrfD-0007T1-4x for pgsql-performance@postgresql.org; Wed, 11 Sep 2013 21:09:31 +0000 Received: from [10.1.1.3] (60-234-150-59.bitstream.orcon.net.nz [60.234.150.59]) (authenticated bits=0) by mbx.knossos.net.nz (8.14.4/8.14.4) with ESMTP id r8BL8rk9030802 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 12 Sep 2013 09:09:00 +1200 Message-ID: <5230DBAE.20108@archidevsys.co.nz> Date: Thu, 12 Sep 2013 09:07:58 +1200 From: Gavin Flower Organization: ArchiDevSys User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: Giuseppe Broccolo CC: pgsql-performance@postgresql.org Subject: Re: Reasons for choosing one execution plan over another? References: <5230A08A.7050001@2ndquadrant.it> In-Reply-To: <5230A08A.7050001@2ndquadrant.it> Content-Type: multipart/alternative; boundary="------------050203050209010302080000" X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org This is a multi-part message in MIME format. --------------050203050209010302080000 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/09/13 04:55, Giuseppe Broccolo wrote: > Il 11/09/2013 13:16, Mikkel Lauritsen ha scritto: >> Hi all, >> >> I have a number of Postgres 9.2.4 databases with the same schema but >> with >> slightly different contents, running on small servers that are basically >> alike (8-16 GB ram). >> > I think that your answer can be found in your statement "slightly > different contents". Planner choices query execution plans basing on > statistics obtained during ANALYSE operations, including the > autovacuum. In this way, Planner can decide which execution plan is > the most suitable. Different content of values in your table could > correspond to different statistical distribution of values in your > columns and of rows in your tables, bringing to different choices of > the Planner. Execution times can be very different, also by factor > 10-100. > > There is a parameter (stat_target) which set the "selectivity" of > statistical samples of a table. Maybe, but it's not necessarily true, > you could obtain more comparable execution times for the two execution > plans changing it, probably increasing them. > > Giuseppe. > Even identical content could lead to different plans, as the sampling is done randomly (or at least 'randomly' according to the documentation). --------------050203050209010302080000 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 12/09/13 04:55, Giuseppe Broccolo wrote:
Il 11/09/2013 13:16, Mikkel Lauritsen ha scritto:
Hi all,

I have a number of Postgres 9.2.4 databases with the same schema but with
slightly different contents, running on small servers that are basically
alike (8-16 GB ram).

I think that your answer can be found in your statement "slightly different contents". Planner choices query execution plans basing on statistics obtained during ANALYSE operations, including the autovacuum. In this way, Planner can decide which execution plan is the most suitable. Different content of values in your table could correspond to different statistical distribution of values in your columns and of rows in your tables, bringing to different choices of the Planner. Execution times can be very different, also by factor 10-100.

There is a parameter (stat_target) which set the "selectivity" of statistical samples of a table. Maybe, but it's not necessarily true, you could obtain more comparable execution times for the two execution plans changing it, probably increasing them.

 Giuseppe.

Even identical content could lead to different plans, as the sampling is done randomly (or at least 'randomly' according to the documentation).
--------------050203050209010302080000--