Redshift Table – Find Last Date of Query on a Table

Question:

I am trying to clean up my small database and trying to see when the last time some of the tables were actually queried but cannot seem to find any documentation on how to do this. I can get the listing of all of the tables in my schema and the sizes, but cannot identify what might be stale before polling my users.

Does anyone know of a way to get the last date that a table was used/queried in redshift?

Answer:

You can see when the table was last scanned in stl_scan. Almost all select queries will scan. The following is taken from: https://github.com/awslabs/amazon-redshift-utils/blob/master/src/AdminViews/v_extended_table_info.sql As you’ve noted the history is only held for a limited period.

Leave a Reply