Reputation: 2116
I can query for storage size of a table in BigQuery using SELECT size_bytes FROM dataset.__TABLES__ WHERE table_id='mytable'
, but this only works for finding total size of table. How to get size of a specific partition from a time-partitioned table, for example I want to find out how much data is stored in mytable$20180701.
I know I can for example copy that partition to a non-partitioned table and use the method above, but I feel this can't be the right method.
Upvotes: 2
Views: 4724
Reputation: 665
In the latest BQ versions there is a preview of PARTITIONS view. The way to get the bytes of a partition for a table is:
SELECT
TOTAL_LOGICAL_BYTES
FROM
`your_project.your_dataset.INFORMATION_SCHEMA.PARTITIONS`
WHERE
TABLE_NAME = 'your_table'
AND
PARTITION_ID = '20240610' # Partition date in yyyymmdd
;
Upvotes: 1
Reputation: 41
In order to access pseduo columns like PARTITIONS_SUMMARY, _PARTITIONTIME you can follow the below steps.
This will work for fetching pseduo columns. uncheck the Legacy option when not required.
Upvotes: 0
Reputation: 173046
You can use dryRun
for this - or in UI just type SELECT * FROM mytable$20180701
and see in Validator
how much bytes will be processed - this is the size of the table
Upvotes: 5