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;当你使用HEAP表时,这里是你应该考虑的一些事情:
相关帮助:
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.