Hi hackers, I noticed that BufferUsage counters' values are strangely different for the same queries on REL_15_STABLE and REL_16_STABLE. For example, I run
CREATE EXTENSION pg_stat_statements; CREATE TEMP TABLE test(b int); INSERT INTO test(b) SELECT generate_series(1,1000); SELECT query, local_blks_hit, local_blks_read, local_blks_written, local_blks_dirtied, temp_blks_written FROM pg_stat_statements; and output on REL_15_STABLE contains query | INSERT INTO test(b) SELECT generate_series($1,$2) local_blks_hit | 1005 local_blks_read | 2 local_blks_written | 5 local_blks_dirtied | 5 temp_blks_written | 0 while output on REL_16_STABLE contains query | INSERT INTO test(b) SELECT generate_series($1,$2) local_blks_hit | 1006 local_blks_read | 0 local_blks_written | 0 local_blks_dirtied | 5 temp_blks_written | 8 I found a bug that causes one of the differences. Wrong counter is incremented in ExtendBufferedRelLocal(). The attached patch fixes it and should be applied to REL_16_STABLE and master. With the patch applied output contains query | INSERT INTO test(b) SELECT generate_series($1,$2) local_blks_hit | 1006 local_blks_read | 0 local_blks_written | 8 local_blks_dirtied | 5 temp_blks_written | 0 I still wonder why local_blks_written is greater than it was on REL_15_STABLE, and why local_blks_read became zero. These changes are caused by fcdda1e4b5. This code is new to me, and I'm still trying to understand whether it's a bug in computing the counters or just changes in how many blocks are read/written during the query execution. If anyone can help me, I would be grateful. Best regards, Karina Litskevich Postgres Professional: http://postgrespro.com/