BUG #5095: pg_statio_xxx_sequences does not work

From: "Akira Kurosawa" <kurosawa-akira(at)mxc(dot)nes(dot)nec(dot)co(dot)jp>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5095: pg_statio_xxx_sequences does not work
Date: 2009-10-02 10:59:43
Message-ID: 200910021059.n92AxhjE094604@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5095
Logged by: Akira Kurosawa
Email address: kurosawa-akira(at)mxc(dot)nes(dot)nec(dot)co(dot)jp
PostgreSQL version: 8.3.5, 8.4.1
Operating system: Red Hat EL 5
Description: pg_statio_xxx_sequences does not work
Details:

I found that "pg_statio_xxx_sequences" cannot get statistics about sequence
I/O in version 8.3-8.4.

For example, I executed following SQL on PostgreSQL 8.3.5.

----------
postgres=# SELECT VERSION();
version
----------------------------------------------------------------------------
------------------------
PostgreSQL 8.3.5 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2
20071124 (Red Hat 4.1.2-42)
(1 row)

postgres=# CREATE SEQUENCE test_seq;
CREATE SEQUENCE
postgres=# \x
Expanded display is on.
postgres=# SELECT * FROM pg_statio_all_sequences;
-[ RECORD 1 ]--------
relid | 16415
schemaname | public
relname | test_seq
blks_read | 0
blks_hit | 0

postgres=# SELECT * FROM test_seq;
-[ RECORD 1 ]-+--------------------
sequence_name | test_seq
last_value | 1
increment_by | 1
max_value | 9223372036854775807
min_value | 1
cache_value | 1
log_cnt | 1
is_cycled | f
is_called | f

postgres=# SELECT * FROM pg_statio_all_sequences;
-[ RECORD 1 ]--------
relid | 16415
schemaname | public
relname | test_seq
blks_read | 0
blks_hit | 0

----------

This result shows that "stats collector" couldn't collect sequence I/O
statistics for "pg_statio_all_sequences",
because "blks_read" and "blks_hit" were not counted.

PostgreSQL 8.4.1 also shows the same result.

This problem happens because "pgstat_info" was not initialized in the
function
"pgstat_initstats" when relkind = 'S'. (pgstat_info = NULL).

I built PostgreSQL 8.4.1 with the following patch,
then executed same SQL.
It seems to work correctly.

*** old/pgstat.c 2009-06-11 23:49:01.000000000 +0900
--- new/pgstat.c 2009-09-15 11:53:30.000000000 +0900
***************
*** 1413,1419 ****
/* We only count stats for things that have storage */
if (!(relkind == RELKIND_RELATION ||
relkind == RELKIND_INDEX ||
! relkind == RELKIND_TOASTVALUE))
{
rel->pgstat_info = NULL;
return;
--- 1413,1420 ----
/* We only count stats for things that have storage */
if (!(relkind == RELKIND_RELATION ||
relkind == RELKIND_INDEX ||
! relkind == RELKIND_TOASTVALUE ||
! relkind == RELKIND_SEQUENCE))
{
rel->pgstat_info = NULL;
return;

----------
postgres=# SELECT VERSION();
version
----------------------------------------------------------------------------
--------------------------------
PostgreSQL 8.4.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2
20071124 (Red Hat 4.1.2-42), 32-bit
(1 row)

postgres=# CREATE SEQUENCE test_seq;
CREATE SEQUENCE
postgres=# \x
Expanded display is on.
postgres=# SELECT * FROM pg_statio_all_sequences;
-[ RECORD 1 ]--------
relid | 16408
schemaname | public
relname | test_seq
blks_read | 1
blks_hit | 1

postgres=# SELECT * FROM test_seq;
-[ RECORD 1 ]-+--------------------
sequence_name | test_seq
last_value | 1
start_value | 1
increment_by | 1
max_value | 9223372036854775807
min_value | 1
cache_value | 1
log_cnt | 1
is_cycled | f
is_called | f

postgres=# SELECT * FROM pg_statio_all_sequences;
-[ RECORD 1 ]--------
relid | 16408
schemaname | public
relname | test_seq
blks_read | 1
blks_hit | 2

----------

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2009-10-02 15:40:27 Re: BUG #5094: bad result in dblink_get_result when async command sending
Previous Message Peter Eisentraut 2009-10-02 07:54:53 Re: BUG #5092: to_ascii(); ascii() don't work with bytea