Search the MySQL manual:

7.4 HEAP Tables

HEAP tables use hashed indexes and are stored in memory. This makes them very fast, but if MySQL crashes you will lose all data stored in them. HEAP is very useful for temporary tables!

The MySQL internal HEAP tables use 100% dynamic hashing without overflow areas. There is no extra space needed for free lists. HEAP tables also don't have problems with delete + inserts, which normally is common with hashed tables:

mysql> CREATE TABLE test TYPE=HEAP SELECT ip,SUM(downloads) AS down
    ->                   FROM log_table GROUP BY ip;
mysql> SELECT COUNT(ip),AVG(down) FROM test;
mysql> DROP TABLE test;

Here are some things you should consider when you use HEAP tables:

The memory needed for one row in a HEAP table is:

SUM_OVER_ALL_KEYS(max_length_of_key + sizeof(char*) * 2)
+ ALIGN(length_of_row+1, sizeof(char*))

sizeof(char*) is 4 on 32-bit machines and 8 on 64-bit machines.

User Comments

Posted by John Lim on Friday May 17 2002, @6:24am[Delete] [Edit]

I have benchmarked inserts and deletes on MyISAM
and HEAP tables. HEAP tables appear to be at
least 30% faster on inserts but only 15% faster
when selecting single records. MyISAM table
caching is pretty fast. I also did some
benchmarks on Oracle for comparison. See
http://php.weblogs.com/oracle_mysql_performance
for further details.

Posted by BAIJUN LI on Monday September 2 2002, @11:36am[Delete] [Edit]

Intel's Itanium and the latest Itanium 2 based
x86 machines have the capacity of supporting
memory much bigger than 64GB as they are 64
bit based processor.

Add your own comment.