0

Does sql keep a record of composite keys or does it calculate them each time a record is inserted/deleted/updated...?

If it does is there a way to call it without having to get each member field value, something like ...WHERE composite_pk=CONCAT('value1','value2','value3')

G-Nugget
  • 8,666
  • 1
  • 24
  • 31
Magic Lasso
  • 1,504
  • 5
  • 22
  • 29

1 Answers1

1

That is correct, composite index is updated when field value is changed. But index has to be unique, otherwise MySql won't allow you to save a changed value. (you'll see an error: #1062 - Duplicate entry 'a-b-c' for key 'x')

Index can't be used in WHERE statement.

useful read: http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html

Also about index Hinting (use, ignore, force): http://dev.mysql.com/doc/refman/5.1/en/index-hints.html

Scherbius.com
  • 3,396
  • 4
  • 24
  • 44