P
P
Puma Thailand2012-01-11 19:18:53
MySQL
Puma Thailand, 2012-01-11 19:18:53

Do mysql update queries use indexes?

When I try to check with explain it swears at the syntax.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
D
dmitryklerik, 2012-01-11
@dmitryklerik

and if you just write EXPLAIN SELECT with the same parameters for WHERE and see?

M
Melkij, 2012-01-11
@melkij

Are used.

Z
zuborg, 2012-01-11
@zuborg

Used, of course, if the where clause allows it.
Indexes allow you to quickly select the desired rows, and what to do with them - update, delete, give to the client or use in the join - this is the tenth thing.
Even with an insert, an index is needed to check the uniqueness of the field value.

A
Anatoly, 2012-01-11
@taliban

I would say that the indexes that participate in the update increase the update time =)

A
Alexey Sundukov, 2012-01-11
@alekciy

Uh ... what's stopping if you don't look at the source code, then at least read the manual?
“The speed of the write depends on the amount of data being updated and the number of indexes that are updated. Indexes that are not changed do not get updated .
dev.mysql.com/doc/refman/5.0/en/update-speed.html
If an indexed field is not affected during the update, the index is not rebuilt either. All indexes associated with updated fields will be rebuilt. Actually in it also there is a sense of indexes. And what part of the index will be rebuilt and how much effectively depends on the type of index used.

E
egorinsk, 2012-01-12
@egorinsk

Make an InnoDB table of 10 million records and compare, for example, the speed of SELECT by index / without and the speed of UPDATE. I suspect that they are involved in the selection, since UPDATE assumes at the beginning the selection of changed rows.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question