Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
252 views
in Technique[技术] by (71.8m points)

Query result size in snowflake

Is there a way to know the query response size in Snowflake?

For example, in BigQuery we get the size from the temporal table created by BigQuery in a query job.

Thanks!

question from:https://stackoverflow.com/questions/65846422/query-result-size-in-snowflake

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

After you run a query you can always refer back to its cached results. All you need to know is the query id and scan for its results. Then you can determine the size of those results by whatever method you choose to measure the size - for example, the length of json encoding all columns.

In code:

-- run a query then get its id

set last_query_id = (select last_query_id());

select sum(length(to_json(object_construct(a.*)))) table_encoded_size
from table(result_scan($last_query_id)) a;


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...