Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aaPrn-0002pt-Hg for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Feb 2016 15:36:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aaPrn-00019T-4V for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Feb 2016 15:36:11 +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_SHA384:256) (Exim 4.84) (envelope-from ) id 1aaK4i-00039G-Ub for pgsql-bugs@postgresql.org; Mon, 29 Feb 2016 09:25:08 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aaK4d-0002g8-RD for pgsql-bugs@postgresql.org; Mon, 29 Feb 2016 09:25:07 +0000 MIME-Version: 1.0 Subject: BUG #13995: Inconsistent exucution plan while using enable_nestloop To: pgsql-bugs@postgresql.org From: eyal@impactsoft.co.il Date: Mon, 29 Feb 2016 09:24:28 +0000 Message-ID: <20160229092428.10548.42478@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 13995 Logged by: Eyal Email address: eyal@impactsoft.co.il PostgreSQL version: 9.5.1 Operating system: centos 6.7 Description: Hi, I checked the TODO list and in the FAQ, there are some items that looks similar, but I do not really know if any of them are actually the same as the following. This may sound like a typical performance issue, but it's actually a bug, because the plan chosen by the optimizer is inconsistent: right after creating the function, it's execution time is ~0.05 seconds. EXACTLY 5 time's it's ~0.05, and than, from the 6th execution onwards, it executes ~1.3 seconds (and sometimes ~46 seconds, probably right after VACUUM ANALYZE). We created a database that reproduce this bug. We first faced this bug in pg9.3.10 on centos6.7 (16GB ram, shared_buffers = 3072MB ). but we actually reproduced it on other systems: a. oracle virtualbox: centos6.7 pg9.3.10 and pg9.5.1 b. windows 7 pg9.3.10, pg9.4.6 and pg9.5.1 To reproduce the bug: 1. restore this databse: https://drive.google.com/file/d/0Byp05k27v6xzUWktNm9ySk1uNVk/view?usp=sharing 2. anslyze all tables (please DO NOT VACUUM. see remark below) 3. create the function: https://drive.google.com/file/d/0Byp05k27v6xzOFlVRUFPenkyZ1k/view?usp=sharing 4. execute the function 6 times: select runtest_with_ENABLE_NESTLOOP(320,cast(1 as smallint),0,200001865232,3202111102000000,cast(-1 as smallint),7045,4); Remark: After VACUUM FULL ANALYZE it's always ~46 seconds (from the first run). than, right after VACUUM ANALYZE (not FULL), it's exactly 5 times ~0.02 seconds, and than, form the 6th onwards, it's ~27seconds Best regards, Eyal. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs