Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda