Thread: Null database entry in pg_stat_database on pg-12 version

Null database entry in pg_stat_database on pg-12 version

From
RAJAMOHAN
Date:
Hello all,

Today I came across this null database entry with oid as 0 in pg_stat_database on postgresql-12 version.  

Any particular use case is there for this?  It also has some column values, how it is gathering those data and which database is responsible for this?

I am not seeing this in the postgresql-10 version.

Can someone clarify this?

postgres=# select * from pg_catalog.pg_stat_database where datid='0';
-[ RECORD 1 ]---------+------------------------------
datid                        | 0
datname                  |
numbackends          | 0
xact_commit            | 0
xact_rollback           | 0
blks_read                 | 14253
blks_hit                     | 1753072
tup_returned             | 271673
tup_fetched               | 212113
tup_inserted              | 152603
tup_updated              | 478
tup_deleted               | 14
conflicts                     | 0
temp_files                  | 0
temp_bytes                | 0
deadlocks                  | 0
checksum_failures     |
checksum_last_failure |
blk_read_time              | 0
blk_write_time              | 0
stats_reset                    | 2021-05-24 08:36:09.580433+00


Thanks & Regards,
Rajamohan.J
Mobile : +91 8098167651, +91 7259157485

Re: Null database entry in pg_stat_database on pg-12 version

From
Magnus Hagander
Date:
On Wed, May 26, 2021 at 9:20 AM RAJAMOHAN <garajamohan@gmail.com> wrote:
>
> Hello all,
>
> Today I came across this null database entry with oid as 0 in pg_stat_database on postgresql-12 version.
>
> Any particular use case is there for this?  It also has some column values, how it is gathering those data and which
databaseis responsible for this?
 

Yes. This is new in PostgreSQL 12
(https://www.postgresql.org/docs/12/release-12.html). It tracks
accesses to shared objects
(https://www.postgresql.org/docs/12/monitoring-stats.html#PG-STAT-DATABASE-VIEW).

-- 
 Magnus Hagander
 Me: https://www.hagander.net/
 Work: https://www.redpill-linpro.com/