Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can MyISAM tables be used more safely?

I like InnoDB's safety, consistency, and self-checking.

But I need MyISAM's speed and light weight.

How can I make MyISAM less prone to corruption due to crashes, bad data, etc.? It takes forever to go through a check (either CHECK TABLE or myisamchk).

I'm not asking for transactional security -- that's what InnoDB is for. But I do want a database I can restart quickly rather than hours (or days!) later.

UPDATE: I'm not asking how to load data into tables faster. I've beat my head against that already, and determined that using the MyISAM tables for my LOAD DATA is simply much faster. What I'm after now is mitigating the risks of using MyISAM tables. That is, reducing chances of damage, increasing speed of recovery.

like image 412
JBB Avatar asked Sep 16 '08 19:09

JBB


People also ask

Why MyISAM gives the best performance?

MyISAM is designed with the idea that your database is queried far more than its updated and as a result it performs very fast read operations. If your read to write(insert|update) ratio is less than 15% its better to use MyISAM.

What is a MyISAM table?

MyISAM stands for Indexed Sequential Access Method. It was the default storage engine for MySQL until December 2009. With the release of MySQL 5.5, MyISAM was replaced with InnoDB. MyISAM is based on an ISAM algorithm that displays information from large data sets fast.

How can I use MyISAM instead of InnoDB?

Convert MyISAM to InnoDB with phpMyAdmin Simply run the ALTER command to convert it to InnoDB storage engine. Note: We always recommend backing up your MySQL database before running any operations on it. ALTER TABLE wp_comments ENGINE=InnoDB; Ensure you are running MySQL 5.6.


1 Answers

MyISAM's supposed speed benefits can actually go away pretty quickly - the fact that it lacks row-level locking means small updates can cause large amounts of data to be locked, and queries to block. Because of that, I'm skeptical of claimed MyISAM speed benefits: start doing several UPDATEs, and the queries per second will tank.

I think you're better off asking "How can applications backed with InnoDB be made faster?" and the answer then deals with caching data, perhaps at the object level, in lightweight caches - there is a cost for ACID, and for, say, web applications, it's not really needed.

If UPDATEs are rare (if they aren't, MyISAM isn't a good choice) then you can even use the MySQL query cache.

memcached (http://www.danga.com/memcached/) is a very popular option for object caching. Depending on your application you have other options as well (HTTP caches, etc.)

like image 179
Daniel Papasian Avatar answered Sep 24 '22 17:09

Daniel Papasian