Re: 答复: [HACKERS] Adding new output parameter of pg_stat_statements toidentify operation of the query.(Internet mail)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jasonysli(李跃森) <jasonysli(at)tencent(dot)com>
Cc: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>, "'husttripper(at)vip(dot)sina(dot)com'" <husttripper(at)vip(dot)sina(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: 答复: [HACKERS] Adding new output parameter of pg_stat_statements toidentify operation of the query.(Internet mail)
Date: 2017-02-20 12:44:13
Message-ID: 28225.1487594653@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

=?gb2312?B?amFzb255c2xpKMDu1L7JrSk=?= <jasonysli(at)tencent(dot)com> writes:
> Yes, it seems the pg_stat_sql function can fit the individual need of collecting tags of query. However the new function can not return other values of query at the same time, such as block number info, run time and so on. Returning these values at the same time are very important.

Meh ... that seems like a justification that was made up on the fly,
rather than being a demonstrable requirement. What's the specific use
case that requires it?

After thinking about this some more I'm really pretty dubious that storing
the command tag will get you anything you can't get as well or better by
looking at the first word or two of the query text. I don't believe the
original claim that doing so is "too expensive for a monitoring system".
It does not take that much to pull out a couple of whitespace-separated
keywords and perhaps case-fold them, and by the time you've fetched the
string out of the database you've spent way more cycles than that.
A slightly better argument is that WITH will confuse matters, but really
it does anyway: consider

WITH x AS (INSERT INTO ... RETURNING *)
SELECT * FROM x;

This will get a command tag of "SELECT", but any reasonable person would
deem that this would be better characterized as an INSERT. So I think
if you want useful results for WITH cases you're going to need to spend
effort looking at the querystring anyway.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2017-02-20 12:49:14 Re: dropping partitioned tables without CASCADE
Previous Message Aleksander Alekseev 2017-02-20 12:41:24 Re: SCRAM authentication, take three