0

I have a table bigger then 15M rows. It has an A.I (id) value and some records deleted for example 5, 2.000.123, 12.000.002. And i want to fill blank id values with the next record.

I thought something like this :

$limit = 1000;
$id = 0;

while($id < $total_record){
    $results = $db->run("select id,mac from logs where id > $id limit $limit");
    foreach($results as $row){
        $id++;
        $db->run("update logs set id = $id where id = $row[id];");
    }
}

$id++;
$db->run("ALTER TABLE logs AUTO_INCREMENT = $id;");

But it takes loooong time (: Is there any way to doing this fast and easy?

0 Answers0