Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Delete and Insert vs Update rows on table

I have a web form in when the user can select many available items (idFamilia) for a single Provider (idProveedor) that looks like this

following item

The values are saved in this table

-----------------------------
| idProveedor | idFamilia   | 
-----------------------------
|      5      |      1      |
-----------------------------
|      5      |      2      |
-----------------------------
|      6      |      2      |
-----------------------------

After a Provider is created, it can be edited and the values selected for idFamilia can be changed. So I have three different scenarios of what could happen:

  • The numbers of rows remain the same and I would only need to edit the values of idFamilia.
  • Some items were deleted from the selection and I would need to search the values on the table and delete those rows.
  • New items are added and I would need to insert those additional values.

Right now I am thinking about just deleting all the rows with the idProveedor that is being edited and just insert the new selection.

Is this a good practice? Will this affect the performance on the long run?

Could you recommend a tutorial or example to do it the other way?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I always go the way to delete and re-create them.

While this adds some performance penalty, it keeps the code simple to understand and easy to maintain. Unless you're Uber, Google, Facebook, Amazon, or other world scale app, the benefits you'd get from optimizing this are much smaller than the cost it incurs: in development, debugging and maintenance time.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!