简体   繁体   中英

MyISAM versus InnoDB simple update performance

I have the following query:

UPDATE `users` SET `time-spent-online` = `time-spent-online` + 10 WHERE `id` = 1

Which for MyISAM table executes:

1 row affected. ( Query took 0.0008 sec )

And for InnoDB table executes:

1 row affected. ( Query took 0.0174 sec )

Is it normal for InnoDB to be this much slower? Should I be using MyISAM instead? I'm afraid of the table-locking of MyISAM. What if I have 1000 users and execute this query for every online user every 10 seconds?

InnoDB shouldn't be much slower than MyIsam. Try to make much more updates and take the average time the query took. The time for only one query is not that acurate.

A word about what I know about MyISAM and InnoDB:

MyISAM is an engine that doesn't suppor transactions and doesn't enforce any kind of referential integrity on the data, nor it allows the usage of transactions (this makes MyISAM very fast to store data, but it's up to you to keep the referential integrity clean by hand ). InnoDB does support transactions and referential integrity, but the trade-off is that it is (a bit) slower than MyISAM.

Simple questions:

  1. Do you need referential integrity?
  2. Do you need to use transactions? (rollbacks)

If your answer is YES to any of the previous questions, InnoDB is the way to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM