Skip to content
Advertisement

Redshift table access history

I wonder are there any way to get table access history in Redshift cluster?

Our cluster has a lot of tables and it is costing us a lot. I would like to discover what specific tables have not been accessed for a given period and then I would drop those tables.

Are there any ways to get table access history? If someone has opinion or materials please let me know.

Thanks.

Advertisement

Answer

To manage disk space, the STL logs (system tables e.g STL_QUERY, STL_QUERYTEXT, ) only retain approximately two to five days of log history (max 7 days) , depending on log usage and available disk space. If you want to retain the log data, you will need to periodically copy it to other tables or unload it to Amazon S3. If you have not copied/exported the stl logs previously, there is no way to access logs of before 1 week.

–>In your case, you can discover which specific tables have not been accessed, only in last 1 week (assuming you have not exported the logs previously). Might be a good idea to check the number of scans on a table with below query to analyse its accessibility.

I came across a similar situation in past, I would suggest to firstly check that the tables are not referred in any procedure or views in redshift with below query:

–>Secondly, if time permits start exporting the redshift stl logs to s3 for few weeks to better explore the least accessed tables.

–> If tables are critical and time does not permit , its better to export the data of the tables to s3 and retain it for few days prior dropping the tables from redshift. It would serve as a backup just in case something goes wrong.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement