I have a setup that kind of mimic in-memory database. I have a table created as memory engine and the same server is configured to act as master and slave. The slave is another database which has the same table structure, but the engine is innodb. Now, we all know that the maximum limits of memory engine and that is restricted to max_heap_table_size. Now that, we have this limitation,I had to ahve some kind of work around. My application was a logger that continuously wrote to this table (no updates/deletes) and then the reporting module read it off the slave for graphs and analytical information.
So I decided to partition the memory engine based table on the master by primary key (hash partition) and there after even after 4M records, i dont see table full error!
Setup uses
MySQL 5.5 / Linux
here is how it is done:-
CREATE TABLE callstack
(
instance_id
bigint(20) NOT NULL AUTO_INCREMENT,
t_thread_id
varchar(64) DEFAULT NULL,
s_id
varchar(64) DEFAULT NULL,
t_host
varchar(30) DEFAULT NULL,
s_t_id
varchar(64) DEFAULT NULL,
p_s_t_id
varchar(64) DEFAULT NULL,
service
varchar(30) DEFAULT NULL,
ipa
varchar(50) DEFAULT NULL,
c_time
bigint(20) DEFAULT NULL,
duration
smallint(6) DEFAULT NULL,
s_host
varchar(30) DEFAULT NULL,
event
varchar(15) DEFAULT NULL,
mode
varchar(10) DEFAULT NULL,
PRIMARY KEY (instance_id
)
) ENGINE=MEMORY DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (instance_id)
PARTITIONS 100 */
Current Table status:=
mysql> show table status like ‘callstack%’;
±----------±-------±--------±-----------±--------±---- -----------±------------±----------------±-------------± ----------±---------------±--------------------±--------- —±-----------±------------------±---------±----------- ----±--------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
±----------±-------±--------±-----------±--------±---- -----------±------------±----------------±-------------± ----------±---------------±--------------------±--------- —±-----------±------------------±---------±----------- ----±--------+
| callstack | MEMORY | 10 | Fixed | 4370554 | 479 | 2095729600 | 0 | 90993600 | 0 | 4370555 | 2013-02-28 10:20:41 | NULL | NULL | latin1_swedish_ci | NULL | partitioned | |
±----------±-------±--------±-----------±--------±---- -----------±------------±----------------±-------------± ----------±---------------±--------------------±--------- —±-----------±------------------±---------±----------- ----±--------+
1 row in set (0.00 sec)
If you observe, the max_data_length shows 0.
max_heap_table_size variable
mysql> show variables like ‘%heap%’;
±--------------------±----------+
| Variable_name | Value |
±--------------------±----------+
| max_heap_table_size | 268435456 |
±--------------------±----------+
1 row in set (0.00 sec)
(256 MB)
Is the memory engine broken or is this a edge case issue? But nonetheless, it is working for me as I wanted! I am trying to figure out how this is working inspite of the heap table restriction. Checked on the disk, if the partitions have created data, but there are only 2 files,callstack.frm and callstack.par.
Will post more details, but if you know anything on the internals, let me know!
Regards,