Search code examples
mysqlinnodbmyisam

How to Tune Storage engine of MySQL


I have database of just 5 million rows, But inner joins and IN taking to much time (55seconds,60seconds). so i am checking if there is a problem with my MyISAM setting.

Query: SHOW STATUS LIKE 'key%'

+------------------------+-------------+
| Variable_name          | Value       |
+------------------------+-------------+
| Key_blocks_not_flushed | 0           | 
| Key_blocks_unused      | 275029      | 
| Key_blocks_used        | 3316428     | 
| Key_read_requests      | 11459264178 | 
| Key_reads              | 3385967     | 
| Key_write_requests     | 91281692    | 
| Key_writes             | 27930218    | 
+------------------------+-------------+

give me your suggestions to increase performance of MyISAM


Solution

  • I have worked with more then 45GB database, I was also faced performance issue,

    Here are the some stpes which I have taken for improve perfomance.

    (1) Remove any unnecessary indexes on the table, paying particular attention to UNIQUE indexes as these disable change buffering. Don't use a UNIQUE index if you have no reason for that constraint; prefer a regular INDEX.

    (2) Inserting in order will result in fewer page splits (which will perform worse on tables not in memory), and the bulk loading is not specifically related to the table size, but it will help reduce redo log pressure.

    (3) If bulk loading a fresh table, delay creating any indexes besides the PRIMARY KEY. If you create them once all data is loaded, then InnoDB is able to apply a pre-sort and bulk load process which is both faster and results in typically more compact indexes. This optimization became true in MySQL 5.5.

    (4) Make sure to use InnoDB instead of MyISAM. MyISAM can be faster at inserts to the end of a table. Innodb is row level locking and MYISAM is table level locking

    (5) Try to avoid complex SELECT queries on MyISAM tables that are updated frequently, and use query like which return less result on first condition

    (6) For MyISAM tables that change frequently, try to avoid all variable-length columns (VARCHAR, BLOB, and TEXT). The table uses dynamic row format if it includes even a single variable-length column