In the previous recipe, we discussed how pg_stat_statements can be used for query analysis. However, some information, such as the CPU (system and user) usage and reads and writes on the filesystem layer, are not visible through pg_stat_statements. For this purpose, we could use the pg_stat_kcache extension, which works in conjunction with pg_stat_statements, to display this information. In this recipe, we shall discuss how pg_stat_kcache can be installed and used to get kernel-level information of a SQL query.
Getting ready
In order to use pg_stat_kcache, we should also the pg_stat_statements have the extension installed and created in the database. This extension is available as an open source project on GitHub (https://github.com/powa-team/pg_stat_kcache) and also made available on the PGDG repository. Similar to any other extension, pg_stat_kcache also has a dependency on the contrib module, that is, the postgresql...