2

My current query to get the table space occupied by the tables in SAMPLE_DB is as below: use role accountadmin; use schema snowflake.INFORMATION_SCHEMA;

SELECT  
   table_name, 
   sum(active_bytes)
 FROM   "INFORMATION_SCHEMA".table_storage_metrics 
  where TABLE_CATALOG in ('SAMPLE_DB') group by table_name;

Question is: do I also need to find out the sum of TIME_TRAVEL_BYTES FAILSAFE_BYTES to get the total space for each table in SAMPLE_DB ?

  • 2
    I think you need all 3, yes, if you care to know the total amount of storage that this table is using. If you want to see the active size of a table, then just the `active_bytes` would be enough. – Mike Walton Jan 04 '21 at 20:42

1 Answers1

0

Yes - plus you will need to include RETAINED_FOR_CLONE_BYTES if that us relevant

NickW
  • 8,430
  • 2
  • 6
  • 19
  • I think most people would consider those bytes as being related to the clone, rather than the original table, though. – Mike Walton Jan 04 '21 at 20:40
  • Fair point. I guess it depends on exactly what the questioner is trying to achieve. If you don't include this storage with the "parent" table then, if you had multiple clones, you could double count it if you associate with the clones - I assume? – NickW Jan 04 '21 at 21:01
  • yep - it depends on whether you are looking for the storage of a table vs. trying to allocate all of the storage to the correct table. The answer is different because of the cloning, and very hard to allocate when you have multiple clones at different points in time. – Mike Walton Jan 04 '21 at 22:40