MySQL Forums
Forum List  »  Memory Storage Engine

Re: How to estimate memory usage ?
Posted by: Ingo Strüwing
Date: December 21, 2006 01:47PM

Hi.

CREATE TABLE `t3` (
`c1` int(11) DEFAULT NULL,
`c2` char(20) DEFAULT NULL,
`c3` char(8) DEFAULT NULL,
KEY `c1` (`c1`),
KEY `c2` (`c2`) USING BTREE,
KEY `c3` (`c3`)
) ENGINE=MEMORY;

Assuming 32-bit machine: sizeof(char*) == 4.
One btree index, key length 20.
Two hash indexes.
Row length 33.

SUM_OVER_ALL_BTREE_KEYS(max_length_of_key + sizeof(char*) × 4)
+ SUM_OVER_ALL_HASH_KEYS(sizeof(char*) × 2)
+ ALIGN(length_of_row+1, sizeof(char*)):

(20 + 4 * 4)
+ 2 * (4 * 2)
+ ALIGN(33 + 1, 4):

(36)
+ 16
+ 36 (34 rounded up to the next multiple of 4):

88 bytes per row. That's what the formula says.

Regards
Ingo

Ingo Strüwing, Senior Software Developer - Storage Engines
MySQL AB, www.mysql.com

Options: ReplyQuote


Subject
Views
Written By
Posted
13200
November 14, 2006 06:45AM
7642
November 20, 2006 09:33AM
6101
December 12, 2006 05:43PM
8517
December 18, 2006 09:45AM
5804
December 21, 2006 11:57AM
Re: How to estimate memory usage ?
6439
December 21, 2006 01:47PM
6270
December 28, 2006 01:50PM
7013
December 28, 2006 03:58PM
5244
January 03, 2007 05:05AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.