On Sat, Nov 17, 2018 at 4:47 AM Haribabu Kommi <[email protected]> wrote: > > 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. There is only one query that is present with that > combination, and that query is deleted. > > In order to avoid such wrong results, i moved this as the first reset query, > so that there will be many queries that satisfy the condition in case if such > mistakes happens. >
Okay, that makes sense.
+--
+-- remove query ('SELECT $1 AS "ONE"') executed by two users
+--
+SELECT pg_stat_statements_reset(NULL,NULL,s.queryid)
+ FROM pg_stat_statements AS s WHERE s.query = 'SELECT $1 AS "ONE"' LIMIT 1;
In the above query, I don't see any advantage of adding LIMIT 1, so
removed in the attached patch. I have also written a commit message
based on what you have written, kindly see if that looks okay to you
especially the credits section.
I am happy with the attached patch and will commit the same by
Wednesday if you or others don't have any further comments.
--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
0001-pg_stat_statements_reset-to-reset-specific-query-use_v13.patch
Description: Binary data
