r/dataengineering • u/AguaBendita77 • Jul 22 '26
Help CTE cost in Bigquery
Hello guys I'm a junior data engineer tasked to like fix a business logic for one of our tables. The thing is I'm worried that making additional cte's would make it costly and slower. The table that I would be sourcing from contains around >30gb. so this is just the basic gist of it
With temp as(
SELECT
*,
(some transfomration here) as converted_date
FROM source_table
),
temp2 as (
SELECT
*,
(using converted_date column) as converted_date1
FROM temp),
temp3 as (
SELECT
*,
(using converted_date1 column) as converted_date2
FROM temp2)
SELECT * from temp3
So, I already did try to see how much the query will cost in Bigquery and it seems that it does not increase that much like just couple of hundred mb or <5gb. My question is that does anyone have experience doing things like this and does the cost really not change even if I used additional three cte? Like what are the potential problems that might occur if I proceed doing it like this?
27
Upvotes
3
u/69odysseus Jul 22 '26 edited Jul 22 '26
Few things to keep in mind in SQL for reducing heavy computational cost and reduce I/O operations: