Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1htxDi-0002B4-AC for pgsql-performance@arkaria.postgresql.org; Sat, 03 Aug 2019 16:49:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1htxDg-0003Sg-Tp for pgsql-performance@arkaria.postgresql.org; Sat, 03 Aug 2019 16:49:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1htxDg-0003SZ-LF for pgsql-performance@lists.postgresql.org; Sat, 03 Aug 2019 16:49:24 +0000 Received: from mout.perfora.net ([74.208.4.196]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1htxDd-0007IM-SF for pgsql-performance@lists.postgresql.org; Sat, 03 Aug 2019 16:49:24 +0000 Received: from [192.168.1.101] ([98.169.208.73]) by mrelay.perfora.net (mreueus001 [74.208.5.2]) with ESMTPSA (Nemesis) id 0MLPtc-1huVBJ0fMA-000gLm; Sat, 03 Aug 2019 18:49:15 +0200 Subject: Re: Strange runtime partition pruning behaviour with 11.4 To: Thomas Kellerer Cc: pgsql-performance@lists.postgresql.org References: <29b2f4c6-987b-d364-2e1d-bbd479d06da2@gmx.net> <9c55d578-bb70-d439-6450-abc291957ec3@gmx.net> From: MichaelDBA Message-ID: Date: Sat, 3 Aug 2019 12:49:14 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 PostboxApp/6.1.18 MIME-Version: 1.0 In-Reply-To: <9c55d578-bb70-d439-6450-abc291957ec3@gmx.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-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audpZrNqYgPP6eEJPwngyXkr/4MlZ+tmFE= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I too got the same plan (non runtime partition pruning plan) with or without the statistics.  So it looks like the workaround until this is fixed is to re-arrange the query to do a subselect to force the runtime partition pruning as Andreas suggested, which I tested and indeed does work for me too! Regards, Michael Vitale Thomas Kellerer wrote on 8/3/2019 10:06 AM: >> it's posible to rewrite the query to: >> >> >> test=# explain analyse select count(*) from foo_bar_baz as fbb where >> foo_id = (select foo_id from foo where foo_name = 'eeny'); >> >> I know, that's not a solution, but a workaround. :-( > > Yes, I discovered that as well. > > But I'm more confused (or concerned) by the fact that the (original) > query works correctly *without* statistics. > > Thomas > > > > >