Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d37Cp-00045k-F9 for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Apr 2017 20:37:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d37Cp-0004Sx-1a for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Apr 2017 20:37:03 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d37BJ-0001pk-1J for pgsql-hackers@postgresql.org; Tue, 25 Apr 2017 20:35:29 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d37BF-0000NO-Ex for pgsql-hackers@postgresql.org; Tue, 25 Apr 2017 20:35:27 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 9A81621C2983; Tue, 25 Apr 2017 23:35:22 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Message-ID: <58FFB309.5040209@postgrespro.ru> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1493152522; bh=ij8HqJ5foofirja56q+/zs2fgbMdLpHmJ/YnVtI2pfg=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=EnxeuequK5gjrBwFmQaXlZqGP2fxQQr8yf7ZVA+uEC4+w+kkhTyl5G65FPuk94AZV 1OzZwFq53IUoMaXVEFL2H1T/aCbclZAl0SOwSHKQFm14r+8YlYOAAKsYbC0EdOOopQ 5npMEdSpMSMJPX7m59zCG9JNNOhXPLlMa8f+ld7Q= Date: Tue, 25 Apr 2017 23:35:21 +0300 From: Konstantin Knizhnik User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: David Fetter CC: pgsql-hackers@postgresql.org Subject: Re: Cached plans and statement generalization References: <8e76d8fc-8b8c-14bd-d4d1-e9cf193a74f5@postgrespro.ru> <20170424184353.u2krt2eiw2l6e2af@alap3.anarazel.de> <20170425165421.GD32130@fetter.org> In-Reply-To: <20170425165421.GD32130@fetter.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 04/25/2017 07:54 PM, David Fetter wrote: > On Tue, Apr 25, 2017 at 06:11:09PM +0300, Konstantin Knizhnik wrote: >> On 24.04.2017 21:43, Andres Freund wrote: >>> Hi, >>> >>> On 2017-04-24 11:46:02 +0300, Konstantin Knizhnik wrote: >>>> So what I am thinking now is implicit query caching. If the same query with >>>> different literal values is repeated many times, then we can try to >>>> generalize this query and replace it with prepared query with >>>> parameters. >>> That's not actuall all that easy: >>> - You pretty much do parse analysis to be able to do an accurate match. >>> How much overhead is parse analysis vs. planning in your cases? >>> - The invalidation infrastructure for this, if not tied to to fully >>> parse-analyzed statements, is going to be hell. >>> - Migrating to parameters can actually cause significant slowdowns, not >>> nice if that happens implicitly. >> Well, first of all I want to share results I already get: pgbench with >> default parameters, scale 10 and one connection: >> >> protocol >> TPS >> simple >> 3492 >> extended >> 2927 >> prepared >> 6865 >> simple + autoprepare >> 6844 > If this is string mashing on the unparsed query, as it appears to be, > it's going to be a perennial source of security issues. Sorry, may be I missed something, but I can not understand how security can be violated by extracting string literals from query. I am just copying bytes from one buffer to another. I do not try to somehow interpret this parameters. What I am doing is very similar with standard prepared statements. And moreover query is parsed! Only query which was already parsed and executed (but with different values of parameters) can be autoprepared. > > Best, > David. -- Konstantin Knizhnik Postgres Professional: http://www.postgrespro.com The Russian Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers