Add index before rewriting existing records.