-- -- It's difficult to come up with platform-independent test cases for -- the pgstattuple functions, but the results for empty tables and -- indexes should be that. --
createtable test (a intprimarykey, b int[]);
select * from pgstattuple('test'); select * from pgstattuple('test'::text); select * from pgstattuple('test'::name); select * from pgstattuple('test'::regclass); select pgstattuple(oid) from pg_class where relname = 'test'; select pgstattuple(relname) from pg_class where relname = 'test';
-- check that using any of these functions with unsupported relations will fail createtable test_partitioned (a int) partition by range (a); createindex test_partitioned_index on test_partitioned(a); createindex test_partitioned_hash_index on test_partitioned using hash(a); -- these should all fail select pgstattuple('test_partitioned'); select pgstattuple('test_partitioned_index'); select pgstattuple_approx('test_partitioned'); select pg_relpages('test_partitioned'); select pgstatindex('test_partitioned'); select pgstatginindex('test_partitioned'); select pgstathashindex('test_partitioned'); select pgstathashindex('test_partitioned_hash_index');
create view test_view asselect1; -- these should all fail select pgstattuple('test_view'); select pgstattuple_approx('test_view'); select pg_relpages('test_view'); select pgstatindex('test_view'); select pgstatginindex('test_view'); select pgstathashindex('test_view');
createforeign data wrapper dummy; create server dummy_server foreign data wrapper dummy; createforeigntable test_foreign_table () server dummy_server; -- these should all fail select pgstattuple('test_foreign_table'); select pgstattuple_approx('test_foreign_table'); select pg_relpages('test_foreign_table'); select pgstatindex('test_foreign_table'); select pgstatginindex('test_foreign_table'); select pgstathashindex('test_foreign_table');
-- a partition of a partitioned table should work though createtable test_partition partition of test_partitioned forvaluesfrom (1) to (100); select pgstattuple('test_partition'); select pgstattuple_approx('test_partition'); select pg_relpages('test_partition');
-- toast tables should work select pgstattuple((select reltoastrelid from pg_class where relname = 'test')); select pgstattuple_approx((select reltoastrelid from pg_class where relname = 'test')); select pg_relpages((select reltoastrelid from pg_class where relname = 'test'));
-- not for the index calls though, of course select pgstatindex('test_partition'); select pgstatginindex('test_partition'); select pgstathashindex('test_partition');
-- an actual index of a partitioned table should work though createindex test_partition_idx on test_partition(a); createindex test_partition_hash_idx on test_partition using hash (a); -- these should work select pgstatindex('test_partition_idx'); select pgstathashindex('test_partition_hash_idx');
-- these should work for sequences create sequence test_sequence; select count(*) from pgstattuple('test_sequence'); select pg_relpages('test_sequence');
-- these should fail for sequences select pgstatindex('test_sequence'); select pgstatginindex('test_sequence'); select pgstathashindex('test_sequence'); select pgstattuple_approx('test_sequence');
drop sequence test_sequence; droptable test_partitioned; drop view test_view; dropforeigntable test_foreign_table; drop server dummy_server; dropforeign data wrapper dummy;
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.