The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/10/static/pgstatstatements.html
Description:
At the top of the pg_stat_statements docs page[1] it states:
"The pg_stat_statements module provides a means for tracking execution
statistics of all SQL statements executed by a server."
This is not strictly true. In cases where large numbers of queries are
cancelled, such as by `statement_timeout` on a loaded server, they are not
in fact recorded by pg_stat_statements. This has been brought up on the
mailing list [2] and has been stated as the intended behavior. This can be
surprising particularly if cancelled queries account for a large amount of
server execution time in pathological cases.
Perhaps a simple change such as this would help clarify this:
"The pg_stat_statements module provides a means for tracking execution
statistics of all SQL statements successfully executed by a server."
Or an explicit callout that cancelled queries do not count regardless of how
much execution time they actually use.
-Casey
[1] https://www.postgresql.org/docs/10/static/pgstatstatements.html
[2]
https://www.postgresql.org/message-id/20171112222811.1464.28388%40wrigleys.postgresql.org