MyISAM vs. InnoDB (@Mail.Ru,2009)

1,282 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,282
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

MyISAM vs. InnoDB (@Mail.Ru,2009)

  1. 1. MyISAM vs. InnoDB Константин Осипов, Staff Engineer Sun/MySQL [email_address] 30 сентября 2009 mail.ru
  2. 2. Содержание <ul><li>таблица сравнения
  3. 3. принципы работы транзакционных БД
  4. 4. как устроен MyISAM
  5. 5. как устроен InnoDB </li></ul>
  6. 6. Таблица сравнения MyISAM InnoDB Нет транзакций Есть транзакции 1 SQL запрос иногда не атомарен SQL всегда атомарен “STRICT” mode не работоспособен “STRICT” mode работает плохо Не crash safe Crash safe
  7. 7. Таблица сравнения (2) MyISAM InnoDB Дедлоки невозможны* Код приложения д.б. готов к дедлокам Каждая табличка: 3 файла: .frm, .myd, .myi A table is stored in a tablespace; 1 tablespace = many files; uncommitted transactions are stored in the log file; + .frm by MySQL
  8. 8. Таблица сравнения (3) MyISAM InnoDB SELECT COUNT(*) is instant SELECT COUNT(*) не быстр :) Нет data cache. Только key cache. Page cache кэширует всё. Несколько key caches. ASSIGN TO KEY CACHE, PRELOAD KEYS Single cache; SELECT * FROM … for warm-up Key cache burst writes Insert buffer
  9. 9. Таблица сравнения (4) MyISAM InnoDB Данные хранятся в порядке вставки В порядке первичного ключа Есть compressed format. Нормальный compressed format. R-tree, B-tree, Fulltext index B+-tree, adaptive hashing No background threads Background write-back threads monitor: overflow, checkpoint, commit
  10. 10. Таблица сравнения (5) MyISAM InnoDB Используется: ????? Wikipedia, YouTube, Slashdot, ... Простота использования Best if run by a DBA <ul>Только в InnoDB: MVCC, ACID, Foreign Keys, Online backup, Point-in-time recovery </ul>
  11. 11. Итог MySQL #support channel (internal IRC), 29-09-2009 ----------------------------------------------------------------------- 22:34 < kostja> do we have widely known customers/community users who use myisam? 22:34 < kostja> like, I know that youtube and wikipedia use innodb; 22:34 < kostja> who does use myisam nowadays? 22:35 < MLord> kostja: not any that I can think of 22:35 < MLord> kostja: most people realize it's generally a bad idea sooner or later 22:35 < kostja> so most people sit in mixed environments at least? 22:35 < MLord> kostja: yeah, most people have at least a few MyISAM tables 22:35 < kostja> MLord: right... 22:36 < James> kostja, mysql. database and temporary tables covers it for most professional installations. Good crash recovery matters and MyISAM doesn't qualify. 22:36 < hartmut> kostja: if it weren't for FULLTEXT and the few GIS users out there it would probably be ready to die 22:38 < MLord> kostja: it's mostly OEMs that still use MyISAM 22:39 < MLord> kostja: partly because it's half the price and partly because that's what they originally used and it takes a long time to make changes 22:37 < kostja> thanks -----------------------------------------------------------------------
  12. 12. Основные концепции РСУБД <ul><li>A tomicity, C onsistency, I solation D urability
  13. 13. Isolation в SQL стандарте выражена через отсутствие фантомов: </li><ul><ul><ul><li>READ UNCOMMITTED
  14. 14. READ COMMITTED
  15. 15. REPEATABLE READ,
  16. 16. SERIALIZABLE </li></ul></ul></ul><li>Реальность: Snapshot isolation
  17. 17. 2PC как механизм достижения сериальности транзакций ( I и С )
  18. 18. WAL для A и D
  19. 19. Deadlock avoidance; deadlock detection </li></ul>
  20. 20. MyISAM locks <ul><li>TL_READ
  21. 21. TL_READ_HIGH_PRIORITY
  22. 22. TL_READ_NO_INSERT
  23. 23. TL_WRITE_ALLOW_WRITE
  24. 24. TL_WRITE_ALLOW_READ
  25. 25. TL_WRITE_CONCURRENT_INSERT
  26. 26. TL_WRITE_DELAYED
  27. 27. TL_WRITE_LOW_PRIORITY
  28. 28. TL_WRITE </li></ul>
  29. 29. Медиаграфия <ul><li>Мануал: http://dev.mysql.com/doc/refman/5.1/en/innodb-transaction-model.html
  30. 30. Википедия: http://en.wikipedia.org/wiki/Snapshot_isolation
  31. 31. Блоги: http://www.mysqlperformanceblog.com/2006/07/03/choosing-proper-innodb_log_file_size/
  32. 32. Презентации Хейки: http://www.innodb.com/wp/2009/05/13/innodb-sessions-at-the-mysql-conference-and-expo-2009/
  33. 33. Статьи: http://www.devarticles.com/c/a/MySQL/How-Logs-Work-On-MySQL-With-InnoDB-Tables/1/
  34. 34. Детали реализации: http://forge.mysql.com/wiki/MySQL_Internals_InnoDB </li></ul>

×