Re: Log size in bytes of query result - Mailing list pgsql-performance

From Dmitry Dolgov
Subject Re: Log size in bytes of query result
Date
Msg-id CA+q6zcWx28OQ0yV9UVENa3JKChUvWi0DZiXOhjT6SeYsg2uEow@mail.gmail.com
Whole thread Raw
In response to Re: Log size in bytes of query result  (Franklin Haut <franklin.haut@gmail.com>)
List pgsql-performance
> On Wed, May 22, 2019 at 2:51 PM Franklin Haut <franklin.haut@gmail.com> 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@zsrv.org> 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



pgsql-performance by date:

Previous
From: Franklin Haut
Date:
Subject: Re: Log size in bytes of query result
Next
From: Mariel Cherkassky
Date:
Subject: pg_restore takes more time on creation of rules