0

I have a big target table that should be merged with small table every day. lets say the granularity fields are x,y,z i.e merge t1 using t2 on (t1.x=t2.x and t1.y=t2.y and t1.z=t2.z)

will it help me to cluster t1 table by one of the granularity fields? does bigquery know how to use the clustering adventage in merge statements?

I couldnt find any official documentation about it.

Pythonist
  • 75
  • 1
  • 7
  • I have found some documentation about [this](https://cloud.google.com/bigquery/docs/using-dml-with-partitioned-tables#using_a_merge_statement). As explained, It goes down to the way the execution plan will work. As you see on the first sample `Using a subquery to filter source data` it will execute it first the subquery and the move with the rest. As an extra note, you will have to check the performance of the query in the UI. You can also check [third party tools](https://medium.com/google-cloud/visualising-bigquery-41bf6833b98) to check more detailed description. – Betjens Jan 20 '22 at 14:49
  • To add more clarity, if you check the next the section `Using a filter in the search_condition of a when_clause` it goes more into detail as its makes use of join, which also gets executed first. – Betjens Jan 24 '22 at 09:39

0 Answers0