Rieback Melanie <melanie@cs.vu.nl> writes:
> To see the current query in PostgreSQL, the normal procedure is to type:
> SELECT current_query FROM pg_stat_activity;
> Now here's my question.. I want PostgreSQL to react sufficiently
> quickly that the result says:
> SELECT current_query FROM pg_stat_activity;
Sorry, there's basically 0 chance of that happening with any
reliability. The stats system is designed not to slow down actual
transactions at all, which is what it would have to do to guarantee
instantaneous response.
You could improve the reaction time by reducing PGSTAT_STAT_INTERVAL
in the source code (see backend/postmaster/pgstat.c), but you'll incur
corresponding increases in overhead, and you'll never get to the point
of certain repeatability.
regards, tom lane