MySQL - question about the MEMORY engine
Posted: Mon May 16, 2011 6:54 pm
Hi All,
I'm currently using a custom session handler in my scripts (the PHPSEC one) so that sessions are stored in my database and not on the server in some random world-readable directory. At the moment the table in question is using MyISAM but I figured that the MEMORY engine would make more sense. However, I've just been on the MySQL site and got confused while reading the following paragraph:

Thanks in advance,
Mecha_Godzilla
I'm currently using a custom session handler in my scripts (the PHPSEC one) so that sessions are stored in my database and not on the server in some random world-readable directory. At the moment the table in question is using MyISAM but I figured that the MEMORY engine would make more sense. However, I've just been on the MySQL site and got confused while reading the following paragraph:
Because my script will be continually adding and deleting rows in this table (as people are logging-in and logging-out) will the memory used for a particular row be freed-up when it is deleted IE the memory will be available for another row to use? The table size doesn't need to be massive because the session data is very small (so I'm not looking to reclaim the memory I've set-aside for the purpose) but what I don't want is a situation where the allocated memory just fills up and fills up with dead entries and I then have to write a script to destroy and then redeclare the table at midnight and hope some poor sucker wasn't using the system at the timeMemory is not reclaimed if you delete individual rows from a MEMORY table. Memory is reclaimed only when the entire table is deleted. Memory that was previously used for rows that have been deleted will be re-used for new rows only within the same table. To free up the memory used by rows that have been deleted, use ALTER TABLE ENGINE=MEMORY to force a table rebuild.
Thanks in advance,
Mecha_Godzilla