hubert depesz lubaczewski <depesz@depesz.com> writes:
> On Thu, Dec 19, 2019 at 12:14:26AM +0800, Kaijiang Chen wrote:
>> BTW, I got the similar result (still see that proc) with "select * from
>> pg_stat_activity":
>> ...
>> state | idle
>> ...
>> query | DEALLOCATE pdo_stmt_00000388
>>
>> Looks not very nice :-)
> not sure what you mean by not nice.
That's a feature not a bug (and yes, the behavior is documented).
People requested that the view continue to display the last query
of an idle session. IIRC, the main argument was that otherwise
it's hard to tell apart a bunch of idle sessions.
If you don't like it, you can always do something like
case when state = idle then null else query end
regards, tom lane