This topic describes how to use the pg_stat_kcache extension to collect statistics on read and write operations in file systems.
Prerequisites
Your RDS instance meets the following requirements:
The RDS instance runs PostgreSQL 10 or later.
The RDS instance runs a minor engine version of 20230830 or later.
ImportantThe extension is supported in minor engine versions that are earlier than 20230830. To standardize extension management and enhance extension security for ApsaraDB RDS for PostgreSQL, ApsaraDB RDS plans to optimize vulnerable extensions in minor engine version iterations. As a result, some extensions can no longer be created for RDS instances that run earlier minor engine versions. For more information, see [Product changes/Feature changes] Limits on extension creation for ApsaraDB RDS for PostgreSQL instances.
If you have created the extension for your RDS instance that runs a minor engine version earlier than 20230830, the extension is not affected.
If this is the first time you create the extension for your RDS instance or re-create the extension, you must update the minor engine version of the RDS instance to the latest version. For more information, see Update the minor engine version.
The pg_stat_kcache extension depends on the pg_stat_statements extension. These extensions must be loaded when the database starts. Make sure that
pg_stat_statements
andpg_stat_kcache
are added to the value of the shared_preload_libraries parameter. For more information, see pg_stat_statements.NoteFor more information about how to modify the shared_preload_libraries parameter, see Manage the parameters of an ApsaraDB RDS for PostgreSQL instance.
Use the extension
We recommend that you use a privileged account to execute the statements that are involved 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();
NoteYou can use any database account to execute the statement.
Reset statistics.
select pg_stat_kcache_reset();
NoteYou can use only privileged accounts to execute the statement.