From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kasahara Tatsuhito <kasahara.tatsuhito@gmail.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13979: Strange pg_stat_statements results with PREPARE/EXECUTE
Date: Tue, 23 Feb 2016 10:38:08 -0500
Message-ID: <929.1456241888@sss.pgh.pa.us> (raw)
In-Reply-To: <CAP0=ZV+gdKVNxoy90-imBOvFR2P2SZXeDDSBaU7=SAGcWxaAmA@mail.gmail.com>
References: <20160223082438.8550.39180@wrigleys.postgresql.org>
<CAKFQuwYQT_03wR346sG5wbdrrap9jX8jWZ-Hh+vStZi4NB++9Q@mail.gmail.com>
<CAP0=ZV+gdKVNxoy90-imBOvFR2P2SZXeDDSBaU7=SAGcWxaAmA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Kasahara Tatsuhito <kasahara.tatsuhito@gmail.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, kasahara.tatsuhito@gmail.com, david.g.johnston@gmail.com
Subject: Re: BUG #13979: Strange pg_stat_statements results with PREPARE/EXECUTE
In-Reply-To: <929.1456241888@sss.pgh.pa.us>
References: <20160223082438.8550.39180@wrigleys.postgresql.org> <CAKFQuwYQT_03wR346sG5wbdrrap9jX8jWZ-Hh+vStZi4NB++9Q@mail.gmail.com> <CAP0=ZV+gdKVNxoy90-imBOvFR2P2SZXeDDSBaU7=SAGcWxaAmA@mail.gmail.com> <929.1456241888@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox