mysql的heap相关
HEAP表格使用一个杂凑(hashed)索引并且存储在内存中。这使他们更快,但是如果MySQL崩溃,你将失去所有存储的数据。HEAP作为临时表很可用!
CREATE TABLE test TYPE=HEAP SELECT ip,SUM(downloads) as down
FROM log_table GROUP BY ip; SELECT COUNT(ip),AVG(down) FROM test;
DROP TABLE test;
相关帮助:
max_heap_table_size
This variable sets the maximum size to which MEMORY tables are allowed to grow.
The value of the variable is used to calculate MEMORY table MAX_ROWS values.
Setting this variable has no effect on any existing MEMORY table,
unless the table is re-created with a statement such as CREATE TABLE or
altered with ALTER TABLE or TRUNCATE TABLE.
The MEMORY (HEAP) Storage Engine
MEMORY tables are never converted to disk tables. To ensure that you
don’t accidentally do anything foolish, you can set the max_heap_table_size
system variable to impose a maximum size on MEMORY tables. For individual tables,
you can also specify a MAX_ROWS table option in the CREATE TABLE statement.