• Neil Conway's avatar
    This patch reduces the size of the message header used by statistics · 48f8eadf
    Neil Conway authored
    collector messages, per recent discussion on pgsql-patches. 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 now 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 database hash table entry, since it doesn't need to
    access anything in the per-db hash table). It would be easy enough
    to retain the old behavior, but AFAICS it is not required.
    48f8eadf
pgstat.h 10.9 KB