page125
108
Database and Table Storage
Minimizing storage costs directly relates to performance tuning, where you can meet
your data resiliency objectives by choosing optimal storage types. The hidden costs can
rapidly escalate.
You must tune your database designs from the outset, and this section delivers
some tools to identify storage costs. You will begin by developing a view called
v_table_storage_metrics
to support a wider suite of attribute reporting used later in
this chapter.
USE ROLE IDENTIFIER ( $tpc_owner_role );
CREATE OR REPLACE VIEW v_table_storage_metrics
AS
SELECT table_catalog||'.'||
table_schema||'.'||
table_name AS path_to_object,
active_bytes /1024/1024 AS active_MB,
active_bytes
/1024/1024/1024 AS active_GB,
active_bytes
/1024/1024/1024/1024 AS active_TB,
time_travel_bytes
/1024/1024/1024 AS time_travel_GB,
failsafe_bytes
/1024/1024/1024 AS failsafe_GB,
retained_for_clone_bytes
/1024/1024/1024 AS retained_for_clone_GB,
clone_group_id,
is_transient,
deleted
FROM snowflake.account_usage.table_storage_metrics;
You can find further information at
https://docs.snowflake.com/en/sql-
reference/account-usage/tables
. Note that all Account Usage Store views experience
data latency of between 45 minutes and 3 hours; therefore, you may not immediately see
the expected results.
ChaPTer 4
MiCro-ParTiTionS