Using gp_relaccess_stats in Yandex MPP Analytics for PostgreSQL
gp_relaccess_stats is a Yandex Cloud extension that collects the access statistics for tables and views. It registers the read, insert, update, and delete operations, as well as the timestamp of the user's last access to the object. The collected data helps find unused or improperly used objects.
Extension settings
| Configuration | Type | Default value | Description |
|---|---|---|---|
gp_relaccess_stats.enabled |
bool |
false |
Turns on the collection of statistics. You can enable this setting at the cluster or database level. We recommend the database level option. |
gp_relaccess_stats.max_tables |
integer |
65536 |
Maximum number of tables for caching statistics. |
gp_relaccess_stats.dump_on_overflow |
bool |
false |
Decides the behavior if gp_relaccess_stats.max_tables is exceeded. If true, the statistics cache is automatically cleared via relaccess_stats_dump(). If false, you get a low-space warning. |
For more information about the extension, see this gp_relaccess_stats guide
Installing gp_relaccess_stats in a Greenplum® cluster
-
Connect to the database as the owner or a user with the
CREATEpermission in the database and run this command:CREATE EXTENSION gp_relaccess_stats; -
Make sure the extension has been installed:
SELECT extname FROM pg_extension;This will bring up the list of extensions installed in the database.
Use cases
-
Create a statistics collection table:
SELECT relaccess_stats_init();The
relaccess_statstable will get new empty entries for each table and partition of the selected database. -
Update the statistics:
SELECT relaccess_stats_update();The
relaccess_statstable will now be populated with statistics from the cache and thepg_statfolder. -
Check the current usage of the statistics cache:
SELECT relaccess.relaccess_stats_fillfactor();This will show the statistics cache fill percentage.
-
Query the
relaccess_statstable for statistical data:SELECT * FROM relaccess_stats;
Greenplum® and Greenplum Database® are registered trademarks or trademarks of Broadcom Inc. in the United States and/or other countries.