blob: 80e4e4ff132962f653d2ff567fb1ecc2c6c9180d [file] [log] [blame]
set optimizer to off;
set max_parallel_workers_per_gather=0;
drop table if exists pg_stat_test;
create table pg_stat_test(a int);
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup
from pg_stat_all_tables where relname = 'pg_stat_test';
schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup
------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------
public | pg_stat_test | 0 | 0 | | | 0 | 0 | 0 | 0 | 0 | 0
(1 row)
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup
from pg_stat_user_tables where relname = 'pg_stat_test';
schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup
------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------
public | pg_stat_test | 0 | 0 | | | 0 | 0 | 0 | 0 | 0 | 0
(1 row)
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
from pg_stat_all_indexes where relname = 'pg_stat_test';
schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
------------+---------+--------------+----------+--------------+---------------
(0 rows)
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
from pg_stat_user_indexes where relname = 'pg_stat_test';
schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
------------+---------+--------------+----------+--------------+---------------
(0 rows)
begin; -- make analyze same transcation with insert to avoid double the pgstat causes by unorder message read.
insert into pg_stat_test select * from generate_series(1, 100);
analyze pg_stat_test;
commit;
create index pg_stat_user_table_index on pg_stat_test(a);
select count(*) from pg_stat_test;
count
-------
100
(1 row)
delete from pg_stat_test where a < 10;
update pg_stat_test set a = 1000 where a > 90;
set enable_seqscan to off;
select pg_sleep(10);
pg_sleep
----------
(1 row)
select * from pg_stat_test where a = 1;
a
---
(0 rows)
reset enable_seqscan;
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze
from pg_stat_all_tables where relname = 'pg_stat_test';
schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------+---------------------
public | pg_stat_test | 12 | 391 | 1 | 0 | 110 | 0 | 19 | 0 | 91 | 19 | 129
(1 row)
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze
from pg_stat_user_tables where relname = 'pg_stat_test';
schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------+---------------------
public | pg_stat_test | 12 | 391 | 1 | 0 | 110 | 0 | 19 | 0 | 91 | 19 | 129
(1 row)
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
from pg_stat_all_indexes where relname = 'pg_stat_test';
schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
------------+--------------+--------------------------+----------+--------------+---------------
public | pg_stat_test | pg_stat_user_table_index | 1 | 1 | 0
(1 row)
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
from pg_stat_user_indexes where relname = 'pg_stat_test';
schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
------------+--------------+--------------------------+----------+--------------+---------------
public | pg_stat_test | pg_stat_user_table_index | 1 | 1 | 0
(1 row)
reset optimizer;
reset max_parallel_workers_per_gather;