Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In 64 bit systems, a 32 bit column occupies less space than a 64 bit one?

Tags:

In MySQL running on a 64bit OS, every column occupies at least 64 bits? A bit would occupy a whole byte? or a whole word?

like image 714
Jader Dias Avatar asked Mar 12 '10 19:03

Jader Dias


2 Answers

Here's what I think you're looking for:

http://dev.mysql.com/doc/refman/5.5/en/storage-requirements.html

"The storage requirements for data vary, according to the storage engine being used for the table in question. Different storage engines use different methods for recording the raw data and different data types. In addition, some engines may compress the information in a given row, either on a column or entire row basis, making calculation of the storage requirements for a given table or column structure [difficult]."

every column occupies at least 64 bits?

Do you actually mean column, or row? I think you mean row, but I'm not entirely sure. I can't quite figure out why you would need to know the size of the column description because AFAIK it takes up O(1) space...

A bit would occupy a whole byte? or a whole word?

In memory: Not sure actually - I'm leaning towards it occupying an entire word so that meaningful comparisons could be made, but I really don't know. Unless you're talking about using the MEMORY storage engine in which case...

On disk: It really does depend on your storage engine (as mdma said) and row sizes vary vastly depending on your storage engine and character set. For example, the article linked above explains some of the optimizations that MyISAM does to record as few bits as needed for each row.

like image 117
iffy Avatar answered Sep 28 '22 08:09

iffy


It will be 32 bit on disk. I don't know about memory, but I do know 32bit numbers will be upcasted to 64 for comparisons (even on 32bit systems, which gives 64 bit systems a bit boost).

like image 33
Evert Avatar answered Sep 28 '22 07:09

Evert