Is this your first time submitting a feature request?
Describe the feature
The MERGE statement is sub-optimized in BigQuery.
This is of course ok for unique keys as this is what we are looking for.
But for the insert_overwrite strategy where we are looking to rows at the partition-level there is a better solution and here is why:
- a
DELETE or INSERT statement is cheapest than a MERGE statement.
- incremental tables are the most expensive tables in real-world projects.
- The
DELETE statement in BigQuery is free at the partition-level.
This has been tested at Carrefour which is my company.
- On this replacement of the
MERGE statement it reduces the cost by 50.4% and the elapsed time by 35.2%
- On the overall procedure it reduces the cost by 26.1% and the elapsed time by 23.1%
This is wrapped in a transaction to avoid deleting rows if any error occurs.
Describe alternatives you've considered
I have considered an alternative to create an additional delete+insert incremental strategy.
But overriding the existing insert_overwrite is the more convenient as this is exactly what we are looking for and the features are the same.
Who will this benefit?
Of course, everyone without any changes.
Are you interested in contributing this feature?
Yes
Anything else?
No response
Is this your first time submitting a feature request?
Describe the feature
The
MERGEstatement is sub-optimized in BigQuery.This is of course ok for unique keys as this is what we are looking for.
But for the
insert_overwritestrategy where we are looking to rows at the partition-level there is a better solution and here is why:DELETEorINSERTstatement is cheapest than aMERGEstatement.DELETEstatement in BigQuery is free at the partition-level.MERGEstatement it reduces the cost by 50.4% and the elapsed time by 35.2%Describe alternatives you've considered
I have considered an alternative to create an additional
delete+insertincremental strategy.But overriding the existing
insert_overwriteis the more convenient as this is exactly what we are looking for and the features are the same.Who will this benefit?
Of course, everyone without any changes.
Are you interested in contributing this feature?
Yes
Anything else?
No response