"Imseih (AWS), Sami" <simseih@amazon.com> writes:
> I wonder if the right answer here is to track fetches as
> a separate counter in pg_stat_statements, in which fetch
> refers to the number of times a portal is executed?
Maybe, but is there any field demand for that?
IMV, the existing behavior is that we count one "call" per overall
query execution (that is, per ExecutorEnd invocation). The argument
that that's a bug and we should change it seems unsupportable to me,
and even the argument that we should also count ExecutorRun calls
seems quite lacking in evidence. We clearly do need to fix the
reported rowcount for cases where ExecutorRun is invoked more than
once per ExecutorEnd call; but I think that's sufficient.
regards, tom lane