Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

There's a production database I'm working on, whose 4 largest tables contain between 4 million and 10 million rows each and about 15 fields each, with indexes on different field types (numbers, varchar and text). The total index_length is 2.2GB and the data_length is 6GB. All these tables use MyISAM and they have a read/write ratio of 66/33.

Here's the output from /etc/init.d/mysql status during idle time:

Server version          5.1.37-1ubuntu5
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/run/mysqld/mysqld.sock
...

Threads: 27  Questions: 5430994  Slow queries: 59  Opens: 298  Flush tables: 1  Open tables: 128  Queries per second avg: 182.695

The number of queries per second is at about 300 during peak time.

In the last couple of weeks the database has become so slow that sometimes queries are locking for 2 minutes or more. So I increased key_buffer_size to 4GB (I have 8GB on the machine). The lock times have decreased but it's still unbearable during peak hours, especially when the reads/writes ration approaches 50/50.

The server is running on a virtual environment so I/O is not great and most of the select queries do a ORDER BY <some_indexed_field> on results sets with an average of 50k rows.

I've successfully tuned this database before when it was still smaller but now I'm stuck.

Update: Disk utilization easily reaches 100% during the day.

share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

You have to use InnoDB. Here is why :

The major advantages of InnoDB over MyISAM

MyISAM is great in a read-heavy environment. Although you can configre private caches on a per-table basis, MyISAM never caches data.

InnoDB is your best bet !!!

CAVEAT

Get enough RAM on the DB Server to cache everything in the InnoDB Buffer Pool (75% of Installed RAM).

share|improve this answer
1  
Agreed, especially for the row-level locking which you appear to need in this instance. –  Dave Rix Oct 10 '11 at 7:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.