# Issue with update\_attributes

**URL:** <https://www.ruby-forum.com/t/issue-with-update-attributes/114309>\
**Category:** Rails\
**Created:** [September 11, 2007, 6:47am UTC](https://www.ruby-forum.com/t/issue-with-update-attributes/114309 "2007-09-11T06:47:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![knarula\_iiitk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b5e925/32.png) [@knarula\_iiitk](https://www.ruby-forum.com/u/knarula_iiitk)\
**Post date:** [September 11, 2007, 6:47am UTC](https://www.ruby-forum.com/t/issue-with-update-attributes/114309/1 "2007-09-11T06:47:20Z")

</div>

Hi,

I have the following question regarding index updates in rails.

Suppose I have a users table with the following columns:  
user\_id (primary key)  
username (index is created on this column)  
name (there is no index on this column)

Assume that the row with user\_id=10 has the following values:  
user\_id=10, username=“guru”, name=“Chandan Rastogi”

Now I do the following:  
user=User.find\_by\_user\_id(10)  
user.update\_attributes(:name =\> “Abhinav Gupta”)

This will issue an update statement as follows:

UPDATE users  
SET name=“Abhinav Gupta”, username=“guru”, user\_id=10  
WHERE user\_id=10

As you can see the value of username is the same as it was before the  
update statement.

However, will the index on the username column be updated because of  
this update statement.(Note: The update statement sets the username as  
well)

I would be grateful if you can let me know a tool using which I can get  
to know what all indexes are updated when an update statement is issued.

Also let me know if there exists a document that provides an answer to  
the problem that I have described above.

The database that I am using is MySql

Thanks  
Kapil
