Jump to content

Recommended Posts

Currently I am storing my session data in a MEMORY table. I noticed though as records get deleted (due to inactivity), overhead is generated. Unfortunately, MEMORY does not offer a OPTIMIZE command, nor can memory really be "optimized" anyways.

 

So, from anyone who has ever done this, what is the best way to go? InnoDB or Memory for this type of situation? If you went with memory, what is the deal with the overhead, and what ways did you use to combat it? Or is this just something that doesn't need any attention?

 

As far as I can understand, MEMORY tables automatically allocates the full amount of possible memory usage by the table, so that memory is not usable by anything else other then the table (whether its full or empty). SO what happens when the deleted rows (and overhead) grow to the size of the total memory allocation?

 

Thanks for the insight.

 

Link to comment
https://forums.phpfreaks.com/topic/59806-which-engine-type-memory-or-innodb/
Share on other sites

So you would recommend storing session data in a memory table? Do you know anything about the overhead phpmyadmin is reporting on it?

I would assume this overhead is representative of gaps in the table... but as I said earlier, since I only use this for summary tables, I don't have this issue.  Be aware that there is no VARCHAR in a temporary table!

Ok, I understand what you are saying now.

 

If anything, I would say that unless this table is regularly emptied through the truncate command, the gaps (overhead) will fill up all of the alloted space.

 

Their is no varchar? Now I am really confused. Why did it let me create varchar columns then?

 

Here is my current table structure for session:

 

-- 
-- Table structure for table `session`
-- 

CREATE TABLE `session` (
  `SessionID` varchar(32) NOT NULL,
  `AccountID` int(20) NOT NULL,
  `Location` varchar(75) NOT NULL,
  `LastMove` int(20) NOT NULL,
  PRIMARY KEY  (`SessionID`)
) ENGINE=MEMORY DEFAULT CHARSET=latin1;

 

Thoughts?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.