This topic describes how to collect statistics on data in cold storage.
Background information
During the dump to cold storage, tables and indexes are compressed. Therefore, the storage space of the data that is stored in cold storage is reduced compared with that of the disk. The statistical rules of data in cold storage are also changed. PolarDB for PostgreSQL provides functions for collecting statistics of data in cold storage.
Create a polar_osfs_toolkit extension
CREATE EXTENSION IF NOT EXISTS polar_osfs_toolkit;Functions
polar_osfs_relation_size
This function returns the actual data size (the "heap" or "B-tree" structure) of the specified table or index, excluding other additional components. If you want to obtain the OSS storage space occupied by the table itself or the basic data of an index, you can use this function, which is similar to the pg_relation_size function.
Syntax
bigint polar_osfs_relation_size(cstring relname);
Parameters
Parameter | Description |
relname | Table name or index name |
polar_osfs_table_size
This function returns the total OSS storage space occupied by a specified table (excluding its indexes), including the data in the table, TOAST data, and related free space map (FSM) and visibility map (VM) files. The function is similar to the pg_table_size function.
Syntax
bigint polar_osfs_table_size(cstring relname);
Parameters
Parameter | Description |
relname | Table name or index name |
polar_osfs_total_relation_size
This function returns the total OSS storage space occupied by the specified table and all its indexes. The value returned by the function is the sum of the occupied storage space returned by the polar_osfs_table_size() and the storage space occupied by all indexes. This function is similar to the pg_total_relation_size function.
Syntax
bigint polar_osfs_table_size(cstring relname);
Parameters
Parameter | Description |
relname | Table name or index name |