Hi there. Since setting up Rudderstack we've seen ...
# support
f
Hi there. Since setting up Rudderstack we've seen a spike in our BigQuery costs and it seems to all boil down to a single query (I'll post a sanitised version of it in the thread) which is being executed very regularly and processes 50GB a pop (which adds up pretty quickly). Is there any way to customise the frequency, or adjust it to better utilise the partitions? Any help would be much appreciated.
Copy code
SELECT
	DISTINCT *
FROM
	(
		SELECT
			id,
			FIRST_VALUE(`column_a` IGNORE NULLS) OVER (
				PARTITION BY id
				ORDER BY
					received_at DESC ROWS BETWEEN UNBOUNDED PRECEDING
					AND UNBOUNDED FOLLOWING
			) AS `column_a`,
			FIRST_VALUE(`column_b` IGNORE NULLS) OVER (
				PARTITION BY id
				ORDER BY
					received_at DESC ROWS BETWEEN UNBOUNDED PRECEDING
					AND UNBOUNDED FOLLOWING
			) AS `column_b`
		FROM
			(
				(
					SELECT
						id,
						`column_a`,
						`column_b`
					FROM
						`rudderstack`.`users_view`
					WHERE
						(
							id in (
								SELECT
									user_id
								FROM
									`rudderstack`.`identifies`
								WHERE
									_PARTITIONTIME = TIMESTAMP('2022-11-24')
									AND user_id IS NOT NULL
									AND loaded_at >= TIMESTAMP('2022-11-24T12:30:41.323Z')
							)
						)
				)
				UNION
				ALL (
					SELECT
						user_id,
						`column_a`,
						`column_b`
					FROM
						`rudderstack`.`identifies`
					WHERE
						_PARTITIONTIME = TIMESTAMP('2022-11-24')
						AND user_id IS NOT NULL
						AND loaded_at >= TIMESTAMP('2022-11-24T12:30:41.323Z')
				)
			)
	)
g
Are you using RudderStack Open-Source or the Cloud version?
f
Open Source
s
This was a part of an attempt to merge your identify events into a more usable users table. This runs every time you run a sync. If you want to reduce the frequency of this query, you can consider changing the Sync Frequency to something higher than 30 min and whatever is suitable for you. All that said, its still surprising that the query is picking up 50 GB at a time. It should ideally not pick any data which is older than a day according to the query.
f
Thanks for the response - we will consider reducing the frequency of the sync. Yeah it's because BigQuery charges by data scanned, not data returned. Since
rudderstack
.
users_view
doesn't utilise the partitions on the
rudderstack
.
users
table it is doing a full table scan of
rudderstack
.
users
(50GB) every execution. So whilst only today's data gets returned we still get billed for the full table scan by GCP. I imagine this would be the case for anyone using open source with BigQuery and the problem only compounds over time - is it worth raising as a GitHub issue somewhere to get fixed?