We're focused on minimizing database queries to reduce costs. Our daily schedule comprises two batches: one at 5 AM for loading staging files from multiple countries, and another at 6 AM for processing data into reporting tables. However, we aim to optimize the 6 AM batch by running it conditionally—specifically, only when there's new data in the staging tables from the 5 AM batch.
Essentially, we're seeking a way to trigger the 6 AM batch based on certain conditions. If these conditions aren't met, we want to exit the batch without executing it to avoid unnecessary costs.
How can we achieve this?