Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc87ff71

Browse files
committed
Expose the estimation of number of changed tuples since last analyze
This value, now pg_stat_all_tables.n_mod_since_analyze, was alreadytracked and used by autovacuum, but not exposed to the user.Mark Kirkwood, review by Laurenz Albe
1 parent9ce9dfd commitc87ff71

File tree

6 files changed

+29
-1
lines changed

6 files changed

+29
-1
lines changed

‎doc/src/sgml/monitoring.sgml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,11 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
950950
<entry><type>bigint</></entry>
951951
<entry>Estimated number of dead rows</entry>
952952
</row>
953+
<row>
954+
<entry><structfield>n_mod_since_analyze</></entry>
955+
<entry><type>bigint</></entry>
956+
<entry>Estimated number of rows modified since this table was last analyzed</entry>
957+
</row>
953958
<row>
954959
<entry><structfield>last_vacuum</></entry>
955960
<entry><type>timestamp with time zone</></entry>

‎src/backend/catalog/system_views.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ CREATE VIEW pg_stat_all_tables AS
405405
pg_stat_get_tuples_hot_updated(C.oid)AS n_tup_hot_upd,
406406
pg_stat_get_live_tuples(C.oid)AS n_live_tup,
407407
pg_stat_get_dead_tuples(C.oid)AS n_dead_tup,
408+
pg_stat_get_mod_since_analyze(C.oid)AS n_mod_since_analyze,
408409
pg_stat_get_last_vacuum_time(C.oid)as last_vacuum,
409410
pg_stat_get_last_autovacuum_time(C.oid)as last_autovacuum,
410411
pg_stat_get_last_analyze_time(C.oid)as last_analyze,

‎src/backend/utils/adt/pgstatfuncs.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extern Datum pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS);
3434
externDatumpg_stat_get_tuples_hot_updated(PG_FUNCTION_ARGS);
3535
externDatumpg_stat_get_live_tuples(PG_FUNCTION_ARGS);
3636
externDatumpg_stat_get_dead_tuples(PG_FUNCTION_ARGS);
37+
externDatumpg_stat_get_mod_since_analyze(PG_FUNCTION_ARGS);
3738
externDatumpg_stat_get_blocks_fetched(PG_FUNCTION_ARGS);
3839
externDatumpg_stat_get_blocks_hit(PG_FUNCTION_ARGS);
3940
externDatumpg_stat_get_last_vacuum_time(PG_FUNCTION_ARGS);
@@ -265,6 +266,22 @@ pg_stat_get_dead_tuples(PG_FUNCTION_ARGS)
265266
}
266267

267268

269+
Datum
270+
pg_stat_get_mod_since_analyze(PG_FUNCTION_ARGS)
271+
{
272+
Oidrelid=PG_GETARG_OID(0);
273+
int64result;
274+
PgStat_StatTabEntry*tabentry;
275+
276+
if ((tabentry=pgstat_fetch_stat_tabentry(relid))==NULL)
277+
result=0;
278+
else
279+
result= (int64) (tabentry->changes_since_analyze);
280+
281+
PG_RETURN_INT64(result);
282+
}
283+
284+
268285
Datum
269286
pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS)
270287
{

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201307031
56+
#defineCATALOG_VERSION_NO201307051
5757

5858
#endif

‎src/include/catalog/pg_proc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,8 @@ DATA(insert OID = 2878 ( pg_stat_get_live_tuplesPGNSP PGUID 12 1 0 0 0 f f f f
25932593
DESCR("statistics: number of live tuples");
25942594
DATA(insertOID=2879 (pg_stat_get_dead_tuplesPGNSPPGUID121000fffftfs1020"26"_null__null__null__null_pg_stat_get_dead_tuples_null__null__null_ ));
25952595
DESCR("statistics: number of dead tuples");
2596+
DATA(insertOID=3177 (pg_stat_get_mod_since_analyzePGNSPPGUID121000fffftfs1020"26"_null__null__null__null_pg_stat_get_mod_since_analyze_null__null__null_ ));
2597+
DESCR("statistics: number of tuples changed since last analyze");
25962598
DATA(insertOID=1934 (pg_stat_get_blocks_fetchedPGNSPPGUID121000fffftfs1020"26"_null__null__null__null_pg_stat_get_blocks_fetched_null__null__null_ ));
25972599
DESCR("statistics: number of blocks fetched");
25982600
DATA(insertOID=1935 (pg_stat_get_blocks_hitPGNSPPGUID121000fffftfs1020"26"_null__null__null__null_pg_stat_get_blocks_hit_null__null__null_ ));

‎src/test/regress/expected/rules.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,7 @@ SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schem
16261626
| pg_stat_get_tuples_hot_updated(c.oid) AS n_tup_hot_upd, +
16271627
| pg_stat_get_live_tuples(c.oid) AS n_live_tup, +
16281628
| pg_stat_get_dead_tuples(c.oid) AS n_dead_tup, +
1629+
| pg_stat_get_mod_since_analyze(c.oid) AS n_mod_since_analyze, +
16291630
| pg_stat_get_last_vacuum_time(c.oid) AS last_vacuum, +
16301631
| pg_stat_get_last_autovacuum_time(c.oid) AS last_autovacuum, +
16311632
| pg_stat_get_last_analyze_time(c.oid) AS last_analyze, +
@@ -1720,6 +1721,7 @@ SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schem
17201721
| pg_stat_all_tables.n_tup_hot_upd, +
17211722
| pg_stat_all_tables.n_live_tup, +
17221723
| pg_stat_all_tables.n_dead_tup, +
1724+
| pg_stat_all_tables.n_mod_since_analyze, +
17231725
| pg_stat_all_tables.last_vacuum, +
17241726
| pg_stat_all_tables.last_autovacuum, +
17251727
| pg_stat_all_tables.last_analyze, +
@@ -1762,6 +1764,7 @@ SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schem
17621764
| pg_stat_all_tables.n_tup_hot_upd, +
17631765
| pg_stat_all_tables.n_live_tup, +
17641766
| pg_stat_all_tables.n_dead_tup, +
1767+
| pg_stat_all_tables.n_mod_since_analyze, +
17651768
| pg_stat_all_tables.last_vacuum, +
17661769
| pg_stat_all_tables.last_autovacuum, +
17671770
| pg_stat_all_tables.last_analyze, +

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp