If you ever, and I think many of use DBAs have, been in the
situation where you are stuck with data in the database that
isn't used and isn't accessed, data which may consist of rows
that are no longer used, data rows that aren't references,
because you don't use FOREIGN KEYs or they weren't applicable in
this case. Or data that was once used, but no longer is.
And in many cases, this data is tucked in among your other good rows of data :-( One way of cleaning up the database in a case like this is to run standard DELETE statements, but there are a few issues with this:
- You may be accessing a lot of data, so this may take a while.
- You will be locking large amount of data for this.
- The join statement to get the data that is no longer used and / or no longer referenced is complex.
- There is no really good way to split this DELETE in smaller chunks, except using LIMIT, but if what …