How to get exact size of a table??
I have a database with k-safe=1. Hence there are two projections (suffixed with b0 and b1) in place of one super projection. So the data for each table is doubled(may be). In this scenario, how can I get the exact size of a table?? AUDIT function does not provide the exact size,so does COLUMN_STORAGE table. Can anyone help me in finding the exact size of a table as well as schema??
0
Comments
I tried the following query. The result seems ok!! Is this enough to get the total_size??
SELECT ANCHOR_TABLE_NAME,
PROJECTION_SCHEMA,
((SUM(USED_BYTES)+SUM(ROS_USED_BYTES))/1024/1024/1024) AS TOTAL_SIZE
FROM PROJECTION_STORAGE WHERE ANCHOR_TABLE_NAME=<TABLE_NAME>
AND ANCHOR_TABLE_SCHEMA=<SCHEMA_NAME>
GROUP BY PROJECTION_SCHEMA,ANCHOR_TABLE_NAME;
Thank a lot for your help!!
SELECT
ANCHOR_TABLE_NAME,
PROJECTION_SCHEMA,
((SUM(USED_BYTES))/1024/1024/1024) AS TOTAL_SIZE
FROM PROJECTION_STORAGE WHERE ANCHOR_TABLE_NAME = <table_name>
AND ANCHOR_TABLE_SCHEMA=<schema>
AND PROJECTION_NAME like '%b0'
GROUP BY PROJECTION_SCHEMA, ANCHOR_TABLE_NAME;
Your observation is correct. Used Bytes is the sum of ROS and WOS used bytes, so Merlin's query is double counting the ROS storage.
If your projection naming convention doesn't end with b0 or you also want to report on store of tables with replicated projection, then the projection name filter in the where clause can also be changed to a subquery on the PROJECTIONS system table.
/Sajan
Last query is close, but it needs a few little tweaks: