So, I have a specific scenario in a project where I'm updating, deleting or adding a bunch of entries in my db. It's just a form that's pre-populated with existing data, if there is any, and if not, it's new data that the user is inputting. What I'm finding is that it's easier to just delete all existing entries when the form submits, then re-insert the data into the db, rather than checking to see if the data exists, than perform updates or deletes for each row.
I'm thinking that it's better to delete the existing rows, then populate new rows. My thinking is that it requires less queries since I'm just deleting and adding, instead of reading all, deleting some, and updating some, so it's less resource intensive. The flip side is that it has the effect of increasing a UID for each newly created row, which can happen at a somewhat fast rate if a lot of forms are saved repeatedly (which they will be). I'm not using the UID for any queries though, so does it have a longer-term negative affect to just keep ticking that upward?
I'm thinking that it's better to delete the existing rows, then populate new rows. My thinking is that it requires less queries since I'm just deleting and adding, instead of reading all, deleting some, and updating some, so it's less resource intensive. The flip side is that it has the effect of increasing a UID for each newly created row, which can happen at a somewhat fast rate if a lot of forms are saved repeatedly (which they will be). I'm not using the UID for any queries though, so does it have a longer-term negative affect to just keep ticking that upward?