Search code examples
mysqlmemory-managementout-of-memorymemory-table

Mysql: what to do when memory tables reach max_heap_table_size?


I'm using a mysql memory table as a way to cache data rows which are read several times. I chose this alternative because I'm not able to use xcache or memcache in my solution. After reading the mysql manual and forum about this topic I have concluded that an error will be raised when the table reaches its maximum memory size. I want to know if there is a way to catch this error in order to truncate the table and free the memory. I don't want to raise the limit of memory that can be used, I need a way to free the memory automatically so the table can continue working.

Thanks.


Solution

  • If you're out of memory, the engine will raise the error 1114 with the following error message:

    The table 'table_name' is full
    

    You should catch this error on the client side and delete some data from the table.