1

I have about 400 million rows. I am using method 1 but 4 hours have passed and it is not finished yet. Do you know if method 2 is better?

Method 1:
SELECT @i:=0;
ALTER TABLE es1 ADD id int unsigned;
UPDATE es1 SET id = @i:=@i+1;

Method 2:
ALTER TABLE es1 ADD id int NOT NULL AUTO_INCREMENT primary key FIRST

Thank you for your help L

  • although, that prior question does not address the issue of speed OR compare it to using an @var. I have no evidence either way - but my gut says method 2 simply because it is an inbuilt capability. But I doubt I would stop a 4 hour process to then experiment. – Paul Maxwell Oct 23 '17 at 06:56
  • It is method 2. much faster – user2392398 Oct 24 '17 at 01:44

0 Answers0