Why are my deleted records still there?

bsoremsugar —  January 7, 2013 — 2 Comments

I came across this forums question recently…

I deleted some leads but their records are still in the “leads” table in MySQL Sugar database, why ?

Yes, you are right, we do what’s known as a “soft delete” of records, meaning we just set a flag on the record to tell the app to ignore the record, but not remove the record itself. This makes things a bit safer in case a user accidentally deletes a record, so the sys admin can simply go flip the flag to bring back the record rather than do a database restore to get it back.

However, there is a performance hit that can happen over time, where if there gets to be a lot of deleted records it can slow down queries quite a bit ( both INSERT/UPDATES and SELECTS as well ). But Sugar has a nice way to deal with this with the ‘Prune Database’ scheduler job.