Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda