Re: [Patch] New pg_stat_tablespace view - Mailing list pgsql-hackers

From shihao zhong
Subject Re: [Patch] New pg_stat_tablespace view
Date
Msg-id CAGRkXqQM90=58C=ht+nEFk7MTp1GMV8F3fw4Jg5z+NM3Wbu=tg@mail.gmail.com
Whole thread
In response to Re: [Patch] New pg_stat_tablespace view  (shihao zhong <zhong950419@gmail.com>)
List pgsql-hackers
Hi Andres,

v8 counts the time in pgstat_count_io_op_time(), next to the per-backend
time. bufmgr.c and localbuf.c call a variant that takes the tablespace OID
as one more argument, and that is their whole change. The last tablespace
entry used is cached, so the usual case is one compare and an add, with no
hash lookup. The times are flushed with the IO stats, so the checkpointer
and bgwriter changes are gone.

It also fixes an assertion failure at shutdown in v7, after dropping a
tablespace the checkpointer had written to. There is a test for it in
029_stats_restart.pl.

As for why, here is one tablespace on a RAM disk and one on the SSD, same
table, same 5000 random lookups, with debug_io_direct=data to keep the OS
cache out:

 tablespace_name | blks_read | blk_read_time | us_per_block
-----------------+-----------+---------------+--------------
 ts_ssd          |      9645 |         667.8 |         69.2
 ts_ram          |      9645 |         170.1 |         17.6

pg_stat_io and pg_stat_database only show the sum.

Regards,
Shihao
Attachment

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: run pgindent in CI
Next
From: Heikki Linnakangas
Date:
Subject: Re: [PATCH] Two remaining shmem attachment issues in single-user mode