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.
NoteThis extension is not supported by ApsaraDB RDS for PostgreSQL instances that run PostgreSQL 17.
Your RDS instance runs a minor engine version of 20230830 or later.
ImportantThis extension is supported in some minor engine versions earlier than 20230830. However, ApsaraDB RDS plans to optimize vulnerable extensions in minor engine version updates for standardized extension management and enhanced security. Therefore, you cannot create this extension for RDS instances that run a minor engine version earlier than 20230830. For more information, see [Product changes/Feature changes] Limits on extension creation for ApsaraDB RDS for PostgreSQL instances.
If you have already created this extension for your RDS instance that runs a minor engine version earlier than 20230830, you can continue using this extension.
If you are creating this extension for the first time or need to recreate the extension for your RDS instance, 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.