Show Most Used Tables In Redshift

SELECT
   *
FROM
   stl_scan ss
   JOIN pg_user pu
      ON ss.userid = pu.usesysid
   JOIN svl_query_metrics_summary sqms
      ON ss.query = sqms.query
   JOIN temp_mone_tables tmt
      ON tmt.table_id = ss.tbl
      AND tmt.table = ss.perm_table_name;
SELECT
   perm_table_name,
   SUM(ROWS),
   SUM(bytes) SUM(fetches)
FROM
   stl_scan
WHERE starttime >= '2018-09-01 00:00:00'
GROUP BY perm_table_name
ORDER BY SUM(bytes) DESC
LIMIT 40;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: