Jump to content

mysql - deleting records or marking them as deleted?


sw45acp

Recommended Posts

I'm interested in knowing which is a better alternative when working with mysql. If a record needs to be deleted using a php script, is it better to actually delete the record itself or instead mark it as deleted, such as having an extra column where deleted = 1 and active = 0.

 

Advantages of not actually deleting the record means that if the deletion was accidental, its still there. However, a disadvantage is that more space is taken up.

 

Fully deleting a record leaves overhead in the table, and if the records have an index that is auto incremented, a number is wasted, not that it means very much.  But if records will be deleted frequently the overhead will get quite large, and can be annoying to have to optimize the table.

 

What do you guys think is the better alternative?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.