Search code examples
sqlgoogle-bigqueryquery-optimizationsql-delete

Reduce the size of a Delete statement in BigQuery


I have the below delete statement as scheduled query and it takes ~270GB to execute. The insert statement for the same dates is much smaller.

Is there a reason that the delete statement is so big and can it be optimized somehow?

DELETE FROM `TABLE`
 WHERE date BETWEEN FORMAT_DATE("%Y%m%d", DATE_SUB(CURRENT_DATE(), INTERVAL 5 DAY)) 
   AND FORMAT_DATE( "%Y%m%d",DATE_SUB(CURRENT_DATE(), INTERVAL 2 DAY))

Solution

  • Thank you for the proposal, Poala! Unfortunately it did not have any effect on the size of the delete statement however i have partitioned the table by date and this has greatly affected the performance!

    It has reduced the size to only ~3GB.