pgstat: reduce message header

From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: pgstat: reduce message header
Date: 2005-05-10 04:14:33
Message-ID: 42803529.9030803@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

This patch reduces the size of the message header used by statistics
collector messages, per recent discussion. This actually required quite
a few changes -- for example, "databaseid != InvalidOid" was used to
check whether a slot in the backend entry table was initialized, but
that no longer works since the slot might be initialized prior to
receiving the BESTART message which contains the database id. We know
use procpid > 0 to indicate that a slot is non-empty.

Other changes:

- various comment improvements and cleanups

- there's no need to zero-out the entire activity buffer in
pgstat_add_backend(), we can just set activity[0] to '\0'.

- remove the counting of the # of connections to a database; this was
not used anywhere

One change in behavior I wasn't sure about: previously, the code would
create a hash table entry for a database as soon as any message was
received whose header referenced that database. Now, we only create hash
table entries as needed (so for example BESTART won't create a hash
table entry, since it doesn't need to access the per-db hash table). Is
it important that we retain the previous behavior? (It would be easy
enough to do by just calling pgstat_get_db_entry() when processing a
BESTART.)

Barring any objections I'll apply this to HEAD tomorrow.

-Neil

Attachment Content-Type Size
pgstat_msg_hdr_cleanup-4.patch text/x-patch 18.8 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2005-05-10 06:14:16 cleanup: remove MemSet() casts
Previous Message Joshua D. Drake 2005-05-10 03:21:26 Re: [HACKERS] read-only database