mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-23 04:20:40 +02:00
GIN posting lists are now encoded using varbyte-encoding, which allows them to fit in much smaller space than the straight ItemPointer array format used before. The new encoding is used for both the lists stored in-line in entry tree items, and in posting tree leaf pages. To maintain backwards-compatibility and keep pg_upgrade working, the code can still read old-style pages and tuples. Posting tree leaf pages in the new format are flagged with GIN_COMPRESSED flag, to distinguish old and new format pages. Likewise, entry tree tuples in the new format have a GIN_ITUP_COMPRESSED flag set in a bit that was previously unused. This patch bumps GIN_CURRENT_VERSION from 1 to 2. New indexes created with version 9.4 will therefore have version number 2 in the metapage, while old pg_upgraded indexes will have version 1. The code treats them the same, but it might be come handy in the future, if we want to drop support for the uncompressed format. Alexander Korotkov and me. Reviewed by Tomas Vondra and Amit Langote.
129 lines
5.5 KiB
Plaintext
129 lines
5.5 KiB
Plaintext
CREATE EXTENSION pgstattuple;
|
|
--
|
|
-- 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.
|
|
--
|
|
create table test (a int primary key, b int[]);
|
|
select * from pgstattuple('test');
|
|
table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent
|
|
-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------
|
|
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
|
|
(1 row)
|
|
|
|
select * from pgstattuple('test'::text);
|
|
table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent
|
|
-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------
|
|
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
|
|
(1 row)
|
|
|
|
select * from pgstattuple('test'::name);
|
|
table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent
|
|
-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------
|
|
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
|
|
(1 row)
|
|
|
|
select * from pgstattuple('test'::regclass);
|
|
table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent
|
|
-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------
|
|
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
|
|
(1 row)
|
|
|
|
select pgstattuple(oid) from pg_class where relname = 'test';
|
|
pgstattuple
|
|
---------------------
|
|
(0,0,0,0,0,0,0,0,0)
|
|
(1 row)
|
|
|
|
select pgstattuple(relname) from pg_class where relname = 'test';
|
|
pgstattuple
|
|
---------------------
|
|
(0,0,0,0,0,0,0,0,0)
|
|
(1 row)
|
|
|
|
select * from pgstatindex('test_pkey');
|
|
version | tree_level | index_size | root_block_no | internal_pages | leaf_pages | empty_pages | deleted_pages | avg_leaf_density | leaf_fragmentation
|
|
---------+------------+------------+---------------+----------------+------------+-------------+---------------+------------------+--------------------
|
|
2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NaN | NaN
|
|
(1 row)
|
|
|
|
select * from pgstatindex('test_pkey'::text);
|
|
version | tree_level | index_size | root_block_no | internal_pages | leaf_pages | empty_pages | deleted_pages | avg_leaf_density | leaf_fragmentation
|
|
---------+------------+------------+---------------+----------------+------------+-------------+---------------+------------------+--------------------
|
|
2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NaN | NaN
|
|
(1 row)
|
|
|
|
select * from pgstatindex('test_pkey'::name);
|
|
version | tree_level | index_size | root_block_no | internal_pages | leaf_pages | empty_pages | deleted_pages | avg_leaf_density | leaf_fragmentation
|
|
---------+------------+------------+---------------+----------------+------------+-------------+---------------+------------------+--------------------
|
|
2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NaN | NaN
|
|
(1 row)
|
|
|
|
select * from pgstatindex('test_pkey'::regclass);
|
|
version | tree_level | index_size | root_block_no | internal_pages | leaf_pages | empty_pages | deleted_pages | avg_leaf_density | leaf_fragmentation
|
|
---------+------------+------------+---------------+----------------+------------+-------------+---------------+------------------+--------------------
|
|
2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NaN | NaN
|
|
(1 row)
|
|
|
|
select pgstatindex(oid) from pg_class where relname = 'test_pkey';
|
|
pgstatindex
|
|
---------------------------
|
|
(2,0,0,0,0,0,0,0,NaN,NaN)
|
|
(1 row)
|
|
|
|
select pgstatindex(relname) from pg_class where relname = 'test_pkey';
|
|
pgstatindex
|
|
---------------------------
|
|
(2,0,0,0,0,0,0,0,NaN,NaN)
|
|
(1 row)
|
|
|
|
select pg_relpages('test');
|
|
pg_relpages
|
|
-------------
|
|
0
|
|
(1 row)
|
|
|
|
select pg_relpages('test_pkey');
|
|
pg_relpages
|
|
-------------
|
|
1
|
|
(1 row)
|
|
|
|
select pg_relpages('test_pkey'::text);
|
|
pg_relpages
|
|
-------------
|
|
1
|
|
(1 row)
|
|
|
|
select pg_relpages('test_pkey'::name);
|
|
pg_relpages
|
|
-------------
|
|
1
|
|
(1 row)
|
|
|
|
select pg_relpages('test_pkey'::regclass);
|
|
pg_relpages
|
|
-------------
|
|
1
|
|
(1 row)
|
|
|
|
select pg_relpages(oid) from pg_class where relname = 'test_pkey';
|
|
pg_relpages
|
|
-------------
|
|
1
|
|
(1 row)
|
|
|
|
select pg_relpages(relname) from pg_class where relname = 'test_pkey';
|
|
pg_relpages
|
|
-------------
|
|
1
|
|
(1 row)
|
|
|
|
create index test_ginidx on test using gin (b);
|
|
select * from pgstatginindex('test_ginidx');
|
|
version | pending_pages | pending_tuples
|
|
---------+---------------+----------------
|
|
2 | 0 | 0
|
|
(1 row)
|
|
|