Ozzy
Ozzy

Reputation: 1730

Speed-up of readonly MyISAM table

We have a large MyISAM table that is used to archive old data. This archiving is performed every month, and except from these occasions data is never written to the table. Is there anyway to "tell" MySQL that this table is read-only, so that MySQL might optimize the performance of reads from this table? I've looked at the MEMORY storage engine, but the problem is that this table is so large that it would take a large portion of the servers memory, which I don't want.

Hope my question is clear enough, I'm a novice when it comes to db administration so any input or suggestions are welcome.

Upvotes: 4

Views: 3234

Answers (3)

Ruben
Ruben

Reputation: 51

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);

Upvotes: 5

ChristopheD
ChristopheD

Reputation: 116137

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)

Upvotes: 1

Cine
Cine

Reputation: 4402

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

Upvotes: 1

Related Questions