This topic describes how to use the pg_stat_kcache extension to collect statistics on read and write operations in file systems.
Prerequisites
- Your ApsaraDB RDS for PostgreSQL instance must meet the following requirements:
- The major engine version of the RDS instance is PostgreSQL 10 or later.
- The minor engine version of the RDS instance is 20230330 or later. For more information about how to view and update the minor engine version of an RDS instance, see Update the minor engine version of an ApsaraDB RDS for PostgreSQL instance. Important This extension is supported in minor engine versions that are earlier than 20230330. However, the extensions that are supported for ApsaraDB RDS for PostgreSQL instances are changed. Starting April 17, 2023, some extensions can no longer be created for RDS instances that run minor engine versions earlier than 20230330. For more information, see [Notice] Starting April 17, 2023, some extensions can no longer be created for ApsaraDB RDS for PostgreSQL instances that run earlier minor engine versions.
- If you have created this extension for your RDS instance that runs a minor engine version earlier than 20230330, the extension is not affected.
- If this is the first time you create this extension for your RDS instance or re-create the extension, you must update the minor engine version of the RDS instance to 20230330 or later. For more information, see Update the minor engine version of an ApsaraDB RDS for PostgreSQL instance.
- The pg_stat_kcache extension depends on the pg_stat_statements extension. These extensions must be loaded when the database starts. Make sure that the names of the
pg_stat_statements
andpg_stat_kcache
extensions are added to the value of the shared_preload_libraries parameter.Note For more information about how to modify the shared_preload_libraries parameter, see Modify the parameters of an ApsaraDB RDS for PostgreSQL instance.
Procedure
Note We recommend that you use a privileged account to execute the statements that are required in this section.
- Create the extension.
CREATE EXTENSION pg_stat_kcache;
- Delete the extension.
DROP EXTENSION pg_stat_kcache;
- Query statistics.
SELECT * FROM pg_stat_kcache();
Note You can use any database account to execute the statement. - Reset statistics.
select pg_stat_kcache_reset();
Note You can use only privileged accounts to execute the statement.