Speed-up of readonly MyISAM table

浪子不回头ぞ 提交于 2019-12-03 17:04:25

Yes, you can compress the myisam tables.

Here is the doc from 5.0 : http://dev.mysql.com/doc/refman/5.0/en/myisampack.html

Instead of un-and re-compressing the history table: If you want to access a single table for the history, you can use a merge table to combine the compressed read-only history tables.

Thus assuming you have an active table and the compressed history tables with the same table structure, you could use the following scheme:

The tables:

compressed_month_1
compressed_month_2
active_month

Create a merge table:

create table history_merge like active_month;
alter table history_merge 
    ENGINE=MRG_MyISAM 
    union (compressed_month_1,compressed_month_2);

After a month, compress the active_month table and rename it to compressed_month_3. Now the tables are:

compressed_month_1
compressed_month_2
compressed_month_3
active_month

and you can update the history table

alter table history_merge 
    union (compressed_month_1, compressed_month_2, compressed_month_3);

You could use myisampack to generate fast, compressed, read-only tables.

(Not really sure if that hurts performance if you have to return most of the rows; testing is advisable; there could be a trade-off between compression and disk reads).

I'd say: also certainly apply the usual:

  1. Provide appropriate indexes (based on the most used queries)
  2. Have a look at clustering the data (again if this is useful given the queries)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!