Deleting and loading bulk data by splitting, merging, and switching partitions (sliding window)
Many times there is a requirement to archive or delete a large amount of data and load a large amount of new data into a large table periodically, based on the date and time column. Let's say for example, you regularly need to delete a large amount of data that belongs to the oldest quarter. At the same time, you want to load a large amount of data into an existing table. With billions of rows in a table, this operation is not trivial and can take hours. However, if you implement table partitioning based on the date and time column, you can perform this task very efficiently.
In this recipe, we will learn how to efficiently delete a large amount of data belonging to one quarter of the year, and load a large amount of data for a whole quarter into an existing table by splitting, merging, and switching partitions.
Assume that we need to store data on a quarterly basis and that data belonging to each...