8 million records (at 7GB!) and it's slow means there is something seriously wrong with your schema. That table would entirely fit in InnoDB Buffer Pool on any modern hardware.<p>I want to see your slow query log.
Just a heads up:
<a href="http://dev.mysql.com/doc/refman/5.1/en/memory-storage-engine.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/memory-storage-engine...</a><p>The MEMORY storage engine (formerly known as HEAP) creates special-purpose tables with contents that are stored in memory. Because the data is vulnerable to crashes, hardware issues, or power outages, only use these tables as temporary work areas or read-only caches for data pulled from other tables.
Or you could actually use something designed for indexing data and searches, like Elasticsearch or Solr.<p>Either solution would have no problem indexing all their data, rather than having to limit it to a subset to fit in a in-memory table.
A better solution, is just to increase your innodb buffer size, you will get virtually same performance as the 'memory' table once all the data is in memory. Plus all the data will be persisted.<p>This is an old, but still very useful script for helping to suggest what settings to tweak: <a href="https://github.com/major/MySQLTuner-perl" rel="nofollow">https://github.com/major/MySQLTuner-perl</a><p><a href="http://dev.mysql.com/doc/refman/5.5/en/innodb-buffer-pool.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.5/en/innodb-buffer-pool.ht...</a>
I am always cautious of memory tables. They don't support transactions, for example, and don't work well multi user.<p>Really, the first stop is to use tokudb backend in mysql. If its still slow, and if you have a small subset that fits in ram, just put that straight into a hash table in app space.
We did something similar at work. We had to poll for changes in a table. So instead of polling the tables we added triggers to insert events to a MEMORY table and polled that table. It performs good enough for us.
> Varchars take up the space for all the chars defined.<p>This only applies to memory tables. For non-memory tables, the size of varchar columns depends on the actual string size.<p>(edited. Thanks for correcting!)