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
pg_stat_tablespace-v8.patch
Description: Binary data
