Bigquery: UNNEST repeated vs flatten table performance

Viewed 441

I am using nested tables with sturct record type with array of fields. On top of it I am using a view, but to reference a particular fied(s) in view I need to unnest the table first, which again makes the result fatten.

So is it wise to already store a data into flatten format or use nested table and use unnest in view? with both the ways i am getting same output.

1 Answers

If you'll store data in the flatten format, then flatten table's size will be larger compared to the original table due to repetition of data in columns which are not repeated in the original table. Larger table's size will result in higher costs for both storage and queries.

But it highly depends on the size of that non-repeated columns and the specific queries you'll use.

You can try both variants and see which one will process less GB when queried with your specific queries. Also take a look at the Execution details(Query plan).

Related