PostgreSQL’s Statistics Collector

postgresql

I am having trouble understanding the Postgresql's Statistics Collector.

Here is the official page of describing the pg_stat_database view.

I performed query on the pg_stat_database view,

 postgres=# select tup_inserted, tup_fetched from pg_stat_database;
 tup_inserted | tup_fetched 
--------------+-------------
            0 |           0
            0 |           0
            0 |      425511
            0 |      407918
            0 |           0
         1011 |      413373
          324 |      360500
         1167 |      345411
         1139 |      346655
          787 |      342410
         1049 |      328089
            0 |      204959
         1646 |      231987
          892 |      205624
           41 |       66538
            0 |       41609
          838 |     2591785
(17 rows)

But these are ridiculous numbers. Even If I combine all my databases' rows, still they won't be equal to this.

What data does this actually tells us ?
And moreover I have not used these databases for weeks, means it is showing me old data.

I want to monitor the number of queries being performed, memory used, clients connected etc.

Is there any kind of tool to monitor my postgresql database ?

Best Answer

You actually have two different questions here. With respect to the numbers shown in pg_stat_database, most of them are cumulative since the last time they were reset, e.g. by pg_stat_reset() or friends. So, for example, if you frequently query a one-row table you will eventually accumulate high numbers of tup_fetched and blk_read_time.