Re: New SQL counter statistics view (pg_stat_sql) - Mailing list pgsql-hackers

From Robert Haas
Subject Re: New SQL counter statistics view (pg_stat_sql)
Date
Msg-id CA+TgmoY9b72JKi1gKZMuX7-WqWw3jjUoBFnoKU-3fgEQf9NayQ@mail.gmail.com
Whole thread Raw
In response to Re: New SQL counter statistics view (pg_stat_sql)  (Haribabu Kommi <kommi.haribabu@gmail.com>)
Responses Re: New SQL counter statistics view (pg_stat_sql)  (Haribabu Kommi <kommi.haribabu@gmail.com>)
List pgsql-hackers
On Thu, Sep 29, 2016 at 1:45 AM, Haribabu Kommi
<kommi.haribabu@gmail.com> wrote:
> Currently, The SQL stats is a fixed size counter to track the all the ALTER
> cases as single counter. So while sending the stats from the backend to
> stats collector at the end of the transaction, the cost is same, because of
> it's fixed size. This approach adds overhead to send and read the stats
> is minimal.
>
> With the following approach, I feel it is possible to support the counter at
> command tag level.
>
> Add a Global and local Hash to keep track of the counters by using the
> command tag as the key, this hash table increases dynamically whenever
> a new type of SQL command gets executed. The Local Hash data is passed
> to stats collector whenever the transaction gets committed.
>
> The problem I am thinking is that, Sending data from Hash and populating
> the Hash from stats file for all the command tags adds some overhead.

Yeah, I'm not very excited about that overhead.  This seems useful as
far as it goes, but I don't really want to incur measurable overhead
when it's in use.  Having a hash table rather than a fixed array of
slots means that you have to pass this through the stats collector
rather than updating shared memory directly, which is fairly heavy
weight.  If each backend could have its own copy of the slot array and
just update that, and readers added up the values across the whole
array, this could be done without any locking at all, and it would
generally be much lighter-weight than this approach.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: simplehash.h typo fix
Next
From: Alvaro Herrera
Date:
Subject: Re: minor issue: \c without parameter disconnect current user