Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jpqWK-0003tQ-1p for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Jun 2020 09:56:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jpqWJ-00023g-07 for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Jun 2020 09:56:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jpqWI-00023Y-PW for pgsql-hackers@lists.postgresql.org; Mon, 29 Jun 2020 09:56:10 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jpqWE-0008Jz-Vh for pgsql-hackers@postgresql.org; Mon, 29 Jun 2020 09:56:09 +0000 Received: from hnk.local (p2604028-ipngn12401funabasi.chiba.ocn.ne.jp [180.1.110.28]) by oss.nttdata.com (Postfix) with ESMTPSA id 4931E6009A; Mon, 29 Jun 2020 18:56:03 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com Subject: Re: track_planning causing performance regression To: Julien Rouhaud Cc: "Tharakan, Robins" , "pgsql-hackers@postgresql.org" References: <2895b53b033c47ccb22972b589050dd9@EX13D05UWC001.ant.amazon.com> <49f15257-2fb8-fd7a-5163-4517e3565e3c@oss.nttdata.com> From: Fujii Masao Message-ID: <3edbb799-965f-b779-300f-27db343f7ca9@oss.nttdata.com> Date: Mon, 29 Jun 2020 18:56:02 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020/06/29 18:53, Julien Rouhaud wrote: > On Mon, Jun 29, 2020 at 11:38 AM Fujii Masao > wrote: >> >>>> Your benchmark result seems to suggest that the cause of the problem is >>>> the contention of per-query spinlock in pgss_store(). Right? >>>> This lock contention is likely to happen when multiple sessions run >>>> the same queries. >>>> >>>> One idea to reduce that lock contention is to separate per-query spinlock >>>> into two; one is for planning, and the other is for execution. pgss_store() >>>> determines which lock to use based on the given "kind" argument. >>>> To make this idea work, also every pgss counters like shared_blks_hit >>>> need to be separated into two, i.e., for planning and execution. >>> >>> This can probably remove some overhead, but won't it eventually hit >>> the same issue when multiple connections try to plan the same query, >>> given the number of different queries and very low execution runtime? >> >> Yes. But maybe we can expect that the idea would improve >> the performance to the near same level as v12? > > A POC patch should be easy to do and see how much it solves this > problem. However I'm not able to reproduce the issue, and IMHO unless > we specifically want to be able to distinguish planner-time counters > from execution-time counters, I'd prefer to disable track_planning by > default than going this way, so that users with a sane usage won't > have to suffer from a memory increase. Agreed. +1 to change that default to off. Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION