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

Commitc173aaf

Browse files
committed
Add test for pg_stat_reset_single_table_counters() on index
stats.sql is already doing some tests coverage on index statistics, byretrieving for example idx_scan and friends in pg_stat_all_tables.pg_stat_reset_single_table_counters() is supported for an index for along time, but the case was never covered.This commit closes the gap, by using this reset function on an index,cross-checking the contents of pg_stat_all_indexes.Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>Discussion:https://postgr.es/m/aN8l182jKxEq1h9f@paquier.xyz
1 parent0c7f103 commitc173aaf

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,27 @@ FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass;
850850
2 | t | 3 | t
851851
(1 row)
852852

853+
-- check the stats in pg_stat_all_indexes
854+
SELECT idx_scan, :'test_last_idx' < last_idx_scan AS idx_ok
855+
FROM pg_stat_all_indexes WHERE indexrelid = 'test_last_scan_pkey'::regclass;
856+
idx_scan | idx_ok
857+
----------+--------
858+
3 | t
859+
(1 row)
860+
861+
-- check that the stats in pg_stat_all_indexes are reset
862+
SELECT pg_stat_reset_single_table_counters('test_last_scan_pkey'::regclass);
863+
pg_stat_reset_single_table_counters
864+
-------------------------------------
865+
866+
(1 row)
867+
868+
SELECT idx_scan FROM pg_stat_all_indexes WHERE indexrelid = 'test_last_scan_pkey'::regclass;
869+
idx_scan
870+
----------
871+
0
872+
(1 row)
873+
853874
-----
854875
-- Test reset of some stats for shared table
855876
-----

‎src/test/regress/sql/stats.sql‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,15 @@ COMMIT;
382382
SELECT seq_scan, :'test_last_seq'= last_seq_scanAS seq_ok, idx_scan, :'test_last_idx'< last_idx_scanAS idx_ok
383383
FROM pg_stat_all_tablesWHERE relid='test_last_scan'::regclass;
384384

385+
-- check the stats in pg_stat_all_indexes
386+
SELECT idx_scan, :'test_last_idx'< last_idx_scanAS idx_ok
387+
FROM pg_stat_all_indexesWHERE indexrelid='test_last_scan_pkey'::regclass;
388+
389+
-- check that the stats in pg_stat_all_indexes are reset
390+
SELECT pg_stat_reset_single_table_counters('test_last_scan_pkey'::regclass);
391+
392+
SELECT idx_scanFROM pg_stat_all_indexesWHERE indexrelid='test_last_scan_pkey'::regclass;
393+
385394
-----
386395
-- Test reset of some stats for shared table
387396
-----

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp