Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1956

updates to secondary indexes (1 reply)

$
0
0
Examples tend to work best:

Suppose I have a table like the following
> desc users
id int auto_increment primary key
first varchar(100)
last varchar(200) not null
...
KEY idx_lname (last) //the secondary index

and data:
> select * from users
1 'ted' 'williams'
2 'babe' 'ruth'
.....

If the following statement (or equivalent prepared statement) is issued:
UPDATE users set first='theodore', last='williams' where id = 1

my question is, will the secondary index 'idx_lname' be updated (delete-mark, insert, purge) or is InnoDB smart enough to recognize that the indexed column ('last') is not changed as a part of the update statement.

Note: this is standard for ORM solutions, which generate the full UPDATE, column for column, whenever issuing an UPDATE. Obviously, I don't want to incur the overhead of a secondary-index update when in fact nothing needs to be updated

Viewing all articles
Browse latest Browse all 1956

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>