> On Wed, May 22, 2019 at 2:51 PM Franklin Haut <franklin.haut@xxxxxxxxx> wrote: > > By my analysis, I see that the most efficient way to perform this control > would be in the existing medium in postgresql that is the log file (pg_log) > adding a few more variables for each query executed. > On Fri, May 10, 2019 at 6:42 PM Sergei Kornilov <sk@xxxxxxxx> wrote: > > We have any hooks that can be used for such purposes? Sometimes I think how > to implement counters "bytes sent to client"/"bytes recv from client" in > pg_stat_statements but did not found good place. Where we can accumulate such > counters and how they can be accessible from extension? Extend DestReceiver > or add counter directly in src/backend/libpq/pqcomm.c ? For the records, I guess on Linux you can gather such kind of information via ebpf, even without hooks in Postgres (if you avoid too frequent context switches between kernel/user space via e.g. relying on send/recv, it should be also efficient). I have a POC in my postgres-bcc repo, it looks like this: $ net_per_query.py bin/postgres -c $container_id attaching... listening... detaching... sent [16397:4026532567] copy pgbench_accounts from stdin: 16b [16397:4026532567] alter table pgbench_accounts add primary key (aid): 96b [16428:4026532567] postgres: backend 16428: 2k received [16397:4026532567] copy pgbench_accounts from stdin: 16m