Hello All.
I have a bq table that is partitioned on one of the date columns. A view was created on top of this tables as (select * from table).
If I use this view to query the table and filter on the partition column then what will happen
a. the query will scan the whole table based on the view definition?
b. bq will intelligently use the partition column filter in my query to select limited data?
Please share your thoughts on this.
~Ashish
Solved! Go to Solution.
BigQuery will intelligently use the partition column filter in your query to select limited data. BigQuery is capable of pruning partitions based on the partition column filter in your query. This means that BigQuery will only scan the partitions that match the filter criteria and skip the remaining partitions. This can significantly improve the performance of your queries, especially if you are querying a large partitioned table.
For example, if you have a table partitioned on a column named <partition_column>
, and you create a view on top of this table as SELECT * FROM table
, then the following query will only scan the partition for data with a value of '2023-10-10'
for that column:
SELECT * FROM view WHERE <partition_column> = '2023-10-10'
However, there are a few things to keep in mind when using partition pruning with views:
If any of these conditions are not met, BigQuery might not be able to prune partitions efficiently and could end up scanning more data than necessary, leading to increased costs and query times.