r/bigquery • u/Expensive-Insect-317 • Sep 21 '26
The BigQuery Join Problem Nobody Notices Until the Data Gets Big
https://medium.com/@sendoamoronta/the-bigquery-join-problem-nobody-notices-until-the-data-gets-big-580b82e2e777A short deep dive into a BigQuery join problem that often goes unnoticed until data gets big shuffle, skew, cardinality and query performance.
11
Upvotes
5
u/reditandfirgetit Sep 21 '26
There is no reason to join on customer_history in your example. Nothing is being used from it and if its a history table you are likely exploding the number of records x how ever many history records there are for each customer
5
u/captain_obvious_here Sep 21 '26
At this point, it is honestly getting quite hard to put BigQuery in a situation where queries become "slow".
The tables volumes you show in your article can be handled without any hiccup if your queries are mere regular joins.
What you pinpoint is not a BQ problem, it's a BQ user not knowing their data and ending up with a Cartesian product. Filtering your data before your JOINs is BQ 101, really, if you don't like paying tens of thousands $ every month.
Also, QUALIFY.
1
u/ArielCoding Sep 24 '26
For the history join, don’t join the full table and filter by date range afterward, shrink customer_history down to one row per customer first, then join. QUALIFY lets you do that filtering in the same step instead of writing a separate CTE.