Add index on table containing more than 3 million rows

Hi ,

Please help me to resolve add index issue on table.

I am having one table , xyz which contains more than 3 million rows.

Now i want to add index on this table.

If we directly add index on this table , it will take too much time…

To resolve this I just thought one solution :

  1. Create new table say xyz_temp with same structure as of xyz
  2. Add the indexes on xyz_temp table.
  3. Transfer records from xyz to xyz_temp table.
  4. rename the xyz table as xyz_old
  5. rename xyz_temp table as xyz
  6. drop xyz_old table

Please let me know whether my approach is correct or not?

Also provide me any better approach.

Thanks in advance.

I would just alter the table and add the indexes.

What are the table’s current fields? Maybe you can make one of those the index, AFAIK that would be faster than ALTER or any kind of copying fandango.
Any of them already UNIQUE?