How to make the mysql MEMORY ENGINE store more data?

前端 未结 5 706
孤独总比滥情好
孤独总比滥情好 2020-12-04 11:45

I want to alter a table from INNODB to MEMORY ENGINE.

So I typed this command:

alter table sns ENGINE=MEMORY;

Then the MySQL shows

5条回答
  •  一向
    一向 (楼主)
    2020-12-04 12:06

    The max size for the memory table is set on creation and altering and based on the max_heap_table_size value.

    So when you want to raise the max size for an existing memory table you can change the max_heap_table_size and then apply it by altering the table to the same storage engine.

    Example:

    # Raise max size to 4GB
    SET max_heap_table_size = 1024 * 1024 * 1024 * 4;
    
    # If already a memory table, the alter will not change anything.
    # Only apply the new max size.
    ALTER TABLE table_name ENGINE=MEMORY;
    

    Misunderstanding regarding tmp_table_size

    The tmp_table_size variable only determines the max size for internal memory tables. Not user-defined.

    As stated in the MySQL docs:

    The maximum size of internal in-memory temporary tables. This variable does not apply to user-created MEMORY tables.

提交回复
热议问题