Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fklwa-00076a-W2 for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Aug 2018 07:53:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fklwZ-0005mC-5W for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Aug 2018 07:53:15 +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.89) (envelope-from ) id 1fklwY-0005m4-RI for pgsql-hackers@lists.postgresql.org; Wed, 01 Aug 2018 07:53:14 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fklwR-0006wB-LX for pgsql-hackers@postgresql.org; Wed, 01 Aug 2018 07:53:14 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 508E221CA105; Wed, 1 Aug 2018 10:53:06 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.1.44] (29.red-83-41-54.dynamicip.rima-tde.net [83.41.54.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 82E7621CA104; Wed, 1 Aug 2018 10:53:05 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1533109986; bh=u2ET5M1KIraZECDIRJxI4r1v4Dlct9Y2hu+LnfZaiXg=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=P9cbhz9a1iuFTg5vjmtpBKAecUQE97qsNDLfjDS/s46w53Y57w7GU5bOg13w1RYUl wsgONsfXjStPNdKAuN8gIkpf2Tej3b4qsqzyX8FNk5+567RsIEF5Hc6igiiI4RECwD jmLo0ZJWIaVV5Q++SCRm1cYVNk/Knw/fi3mshlE8= Subject: Re: [HACKERS] Cached plans and statement generalization To: "Yamaji, Ryo" Cc: PostgreSQL mailing lists References: <4bd78cd4-1e64-5294-2eb8-3d061b20288f@postgrespro.ru> <8eed9c23-19ba-5404-7a9e-0584b836b3f3@postgrespro.ru> <283dfb96-48c2-1a87-90ab-97ca87b237fe@postgrespro.ru> <20180106225118.GS2416@tamriel.snowman.net> <20638bbb-2744-a4ba-116d-084e9c6520bf@postgrespro.ru> <9A6E5062D5D4DB458C80C2B2920BD71D5C2FA8@g01jpexmbkw23> From: Konstantin Knizhnik Message-ID: <157e01d2-30de-0f61-bfa0-d9e1d7dbe66e@postgrespro.ru> Date: Wed, 1 Aug 2018 10:53:03 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <9A6E5062D5D4DB458C80C2B2920BD71D5C2FA8@g01jpexmbkw23> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 31.07.2018 12:12, Yamaji, Ryo wrote: > > 3. I confirmed the transition of the amount of the memory when it tried to prepare query > of the number that exceeded the value specified for autoprepare_limit. > [autoprepare_limit=1 and execute 10 different queries] > plan cache context: 1032 used > plan cache context: 39832 used > plan cache context: 78552 used > plan cache context: 117272 used > plan cache context: 155952 used > plan cache context: 194632 used > plan cache context: 233312 used > plan cache context: 272032 used > plan cache context: 310712 used > plan cache context: 349392 used > plan cache context: 388072 used > > I feel the doubt in an increase of the memory utilization when I execute a lot of > query though cached query is one (autoprepare_limit=1). > This behavior is correct? I failed to reproduce the problem. I used the following non-default configuration parameters: autoprepare_limit=1 autoprepare_threshold=1 create dummy database: create table foo(x integer primary key, y integer); insert into foo values (generate_series(1,10000), 0); and run different queries,  like: postgres=# select *  from foo where x=1; postgres=# select *  from foo where x+x=1; postgres=# select *  from foo where x+x+x=1; postgres=# select *  from foo where x+x+x+x=1; ... and check size of CacheMemoryContext using gdb - it is not increased. Can you please send me your test?