← Back to projects

Dynamic Database Cleanup Job

A self-scheduling background job that purges stale database records based on a configurable rule set. It reads the active rules, calculates its own execution windows, and keeps the database lean without any manual maintenance.

C#.NETSQL ServerBackground Job
Started June 2022Work Project

Databases grow. Without active housekeeping, tables that accumulate transactional or log-style data balloon indefinitely — slowing queries and pushing up storage costs over time.

This cleanup job tackles the problem with a rule-based approach. Each rule defines which table to target, what conditions qualify a row for deletion, and how long data should be retained. The job reads the active rule set at startup, calculates an optimised execution schedule based on those rules, and runs deletions at the right times — no hardcoded cron expression, the schedule adapts to whatever rules are currently active.

Adding a new cleanup policy is a matter of inserting a rule row. Removing one means deactivating it. The job picks up the change on its next cycle without a restart or redeployment.

Built in C# on .NET, targeting SQL Server.