Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aYF2Y-0007ce-5d for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Feb 2016 15:38:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aYF2X-0003Al-Ok for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Feb 2016 15:38:17 +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) (envelope-from ) id 1aYF2W-00037q-Hw for pgsql-bugs@postgresql.org; Tue, 23 Feb 2016 15:38:16 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aYF2P-0007KT-PF for pgsql-bugs@postgresql.org; Tue, 23 Feb 2016 15:38:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u1NFc8Vk000930; Tue, 23 Feb 2016 10:38:08 -0500 From: Tom Lane To: Kasahara Tatsuhito cc: "David G. Johnston" , "pgsql-bugs@postgresql.org" Subject: Re: BUG #13979: Strange pg_stat_statements results with PREPARE/EXECUTE In-reply-to: References: <20160223082438.8550.39180@wrigleys.postgresql.org> Comments: In-reply-to Kasahara Tatsuhito message dated "Wed, 24 Feb 2016 00:24:44 +0900" Date: Tue, 23 Feb 2016 10:38:08 -0500 Message-ID: <929.1456241888@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 Kasahara Tatsuhito writes: > So I expected following result after performing second time "SELECT * > FROM tt WHERE c1 = $1" in a previous e-mail. > =# SELECT queryid, calls, query FROM pg_stat_statements WHERE query LIKE > '%tt%'; > queryid | calls | query > -----------+-------+---------------------------------------------------- > 575935600 | 1| PREPARE p1(int) AS SELECT * FROM tt WHERE c1 = $1; > other-queryid | 10 | SELECT * FROM tt WHERE c1 = $1; > (2 row) > But actually SELECT was counted as PREPARE in pg_stat_statements. > That's what I thought strange. What's in the query field is whatever source string the query was created from. In the case of a prepared statement, we could potentially show either the PREPARE or the EXECUTE, but the former was deemed much more useful. There's no logic in there to invent a string that was never actually submitted to the engine. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs