Forum Moderators: coopster

Message Too Old, No Replies

MySQL index and UPDATE table

When you update a tab with an index, you have to update the index as well?

         

iProgram

11:01 am on Aug 10, 2005 (gmt 0)

10+ Year Member



"When you update a table with an index, you have to update the index as well. "

What does this mean? For example, my table has four columns:
id
name
age
address

and only ID is an index. If I only update the value of age:
UPDATE tab SET age=age+1
or UPDATE tab SET age=20 WHERE id>200

does mysql still have to update the index?

arran

11:46 am on Aug 10, 2005 (gmt 0)

10+ Year Member



Does mysql still have to update the index?

No - mysql only needs to update the index if one or more of the indexed columns is updated.

"When you update a table with an index, you have to update the index as well."

I found the document you were referring to - i think the author is trying to make a general point about the performance implications of inserts/updates/deletes when indexes are defined.