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

150
Vistas
Faster update query for big table

I have a pretty large database which was imported using the csv 'LOAD DATA INFILE' method. Some cells though need to be manipulated and unfortunately i cant do that during the import. I have to do it afterwards since PHP is much easier to play with, not to mention that there are other table cells that need to be changed which is impossible to do with mysql commands. One example of these type of manipulations is the 'Telephone' cell. I have to break the telephone number then update separately 2 different cells of the same row. For example:

$myQ = my_db_query("SELECT companyId, Telephone FROM companies WHERE 1");
while ($row = my_db_fetch_array($myQ))
{
    if($row["Telephone"] != ""){
        $Telefon_area = "";
        $Telefon_num = "";
        $pieces = explode(" ", $row["Telephone"]);
        $Telefon_area = trim( $pieces[0] );
        $Telefon_num  = trim( $pieces[1] );
        my_db_query("UPDATE companies SET `Telefon_area` = '$Telefon_area', `Telefon_num` = '$Telefon_num' WHERE `companyId` = ".$row["companyId"]);
    }
}

The problem i am facing with this approach is that (although i've indexed column Telephone), it is veeeery slow, because i am updating 1.5mil entries.

Is there a faster way of doing this ?

over 4 years ago · Santiago Trujillo
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