Use the following clean-up scripts to help locate redundant queries, widgets, dashboards and alerts within Redash. This was mostly to keep lineage lean and reduce discovery of redundant reports and data:
- locate_expired_assets.sql - Finds expired queries and other assets downstream from that query
- locate_expired_dashboards.sql - Finds unused dashboards older than 1 year
- locate_expired_alerts.sql - Finds unused alerts not executed older than 1 year
- locate_expired_users.sql - Finds unused users not logged older than 90 days
- locate_insecure_tokens.sql - Finds API tokens older than 90 days still in use
- locate_orphaned_connections.sql - Finds orphaned data connections with no queries
- locate_orphaned_visualisations.sql - Finds orphaned visualisations with no widgets
- locate_large_queryresults.sql - Finds top 100 query results saved by size in Mb's
- locate_expired_queryresults.sql - Finds expired query results 90 days, or orphaned user/query.
- remove_expired_assets.sql - Deletes expired queries and other assets downstream from that query
- remove_expired_dashboards.sql - Deletes unused dashboards older than 1 year
- remove_expired_alerts.sql - Deletes unused alerts not executed older than 1 year
- remove_expired_users.sql - Deletes unused users not logged older than 90 days
- remove_insecure_tokens.sql - Deletes API tokens older than 90 days still in use
Use at your own risk. The queries above will only show expired content and users, adapt to your needs.