Re: New function pg_stat_statements_reset_query() to resetstatistics of a specific query

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: New function pg_stat_statements_reset_query() to resetstatistics of a specific query
Дата
Msg-id 20181117111653.cetidngkgol5e5xn@alvherre.pgsql
обсуждение исходный текст
Ответ на Re: New function pg_stat_statements_reset_query() to reset statisticsof a specific query  (Haribabu Kommi <kommi.haribabu@gmail.com>)
Ответы Re: New function pg_stat_statements_reset_query() to reset statisticsof a specific query  (Amit Kapila <amit.kapila16@gmail.com>)
Список pgsql-hackers
On 2018-Nov-17, Haribabu Kommi wrote:

> > Okay, but you haven't answered my question:
> > "how is able to remove the correct statement from hash (it seems
> > statement intended to remove 'SELECT $1 AS "ONE"', but it removed
> > 'SELECT $1 + $2 AS "TWO"')"?
> 
> I missed to check that question.
> 
> SELECT s.queryid FROM pg_stat_statements AS s WHERE s.query =
> 'SELECT $1 AS "ONE"'
> 
> With the above query to get the queryid, but there are no such queries
> present in the pg_stat_statements, so the above query returns NULL as
> output, and with NULL as input to the _reset() function, it takes the
> default value of 0, and the reset query compares with rest of the two
> parameters of userid and dbid.

Uh, ouch!  Seems to me that this is a high-caliber foot-gun, and will
cause nasty suprises when production stats data disappear inadvertently!
Are you sure we wouldn't like to have this functionality not rely on
NULL values to mean "yeah reset everything!"  Seems to me that for safe
production use we would have to tell users to add COALESCE to parameter
values, and it'll be very tedious.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: [HACKERS] pgbench - allow to store select results into variables
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: Undo logs