dbTalk Databases Forums  

Datatypes: BOOL v BIT(1) v TINYINT(1)

comp.databases.mysql comp.databases.mysql


Discuss Datatypes: BOOL v BIT(1) v TINYINT(1) in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Sgt Snorkel
 
Posts: n/a

Default Datatypes: BOOL v BIT(1) v TINYINT(1) - 09-30-2010 , 09:51 AM






If I create a table with 32 columns each declared as BOOL, will the
data be stored as bits (32 bits = 4 bytes) or an individual bytes?
Will each row be 4 bytes or 32?


According to the MySQL website (10.1.1)

http://dev.mysql.com/doc/refman/5.0/...-overview.html

BOOL = BIT(1) = TINYINT(1)

And according 10.2, TINYINT is 1 byte. It also says:

"As of MySQL 5.0.3, a BIT data type is available for storing bit-field
values. (Before 5.0.3, MySQL interprets BIT as TINYINT(1).)"

Thanks

Reply With Quote
  #2  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: Datatypes: BOOL v BIT(1) v TINYINT(1) - 09-30-2010 , 02:37 PM






On 9/30/2010 10:51 AM, Sgt Snorkel wrote:
Quote:
If I create a table with 32 columns each declared as BOOL, will the
data be stored as bits (32 bits = 4 bytes) or an individual bytes?
Will each row be 4 bytes or 32?


According to the MySQL website (10.1.1)

http://dev.mysql.com/doc/refman/5.0/...-overview.html

BOOL = BIT(1) = TINYINT(1)

And according 10.2, TINYINT is 1 byte. It also says:

"As of MySQL 5.0.3, a BIT data type is available for storing bit-field
values. (Before 5.0.3, MySQL interprets BIT as TINYINT(1).)"

Thanks
32 BOOL columns is not the same as one BIT column with 32 values. 32
columns will take 32 TINYINT's.

But why are you prematurely optimizing? Even if you have 1M rows, the
difference is only 31 MB. Design the database properly.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #3  
Old   
Sgt Snorkel
 
Posts: n/a

Default Re: Datatypes: BOOL v BIT(1) v TINYINT(1) - 09-30-2010 , 03:51 PM



On Thu, 30 Sep 2010 15:37:17 -0400, Jerry Stuckle
<jstucklex (AT) attglobal (DOT) net> wrote:

Quote:
On 9/30/2010 10:51 AM, Sgt Snorkel wrote:
If I create a table with 32 columns each declared as BOOL, will the
data be stored as bits (32 bits = 4 bytes) or an individual bytes?
Will each row be 4 bytes or 32?


According to the MySQL website (10.1.1)

http://dev.mysql.com/doc/refman/5.0/...-overview.html

BOOL = BIT(1) = TINYINT(1)

And according 10.2, TINYINT is 1 byte. It also says:

"As of MySQL 5.0.3, a BIT data type is available for storing bit-field
values. (Before 5.0.3, MySQL interprets BIT as TINYINT(1).)"

Thanks

32 BOOL columns is not the same as one BIT column with 32 values. 32
columns will take 32 TINYINT's.
That's what I thought, thanks.

Quote:
But why are you prematurely optimizing? Even if you have 1M rows, the
difference is only 31 MB. Design the database properly.
Because I need to send it from the server to the client over the
Internet. A 32:1 reduction in size is a 32:1 reduction in wait time.

Reply With Quote
  #4  
Old   
Sgt Snorkel
 
Posts: n/a

Default Re: Datatypes: BOOL v BIT(1) v TINYINT(1) - 09-30-2010 , 04:10 PM



On Thu, 30 Sep 2010 15:37:17 -0400, Jerry Stuckle
<jstucklex (AT) attglobal (DOT) net> wrote:

Quote:
On 9/30/2010 10:51 AM, Sgt Snorkel wrote:
If I create a table with 32 columns each declared as BOOL, will the
data be stored as bits (32 bits = 4 bytes) or an individual bytes?
Will each row be 4 bytes or 32?


According to the MySQL website (10.1.1)

http://dev.mysql.com/doc/refman/5.0/...-overview.html

BOOL = BIT(1) = TINYINT(1)

And according 10.2, TINYINT is 1 byte. It also says:

"As of MySQL 5.0.3, a BIT data type is available for storing bit-field
values. (Before 5.0.3, MySQL interprets BIT as TINYINT(1).)"

Thanks

32 BOOL columns is not the same as one BIT column with 32 values. 32
columns will take 32 TINYINT's.

But why are you prematurely optimizing? Even if you have 1M rows, the
difference is only 31 MB. Design the database properly.
PS: Isn't the difference actually 28MB?

PPS: I'm surprised that the database system doesn't pack 32 BOOL
columns into 4 physical bytes so I don't have to worry about it.

Reply With Quote
  #5  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: Datatypes: BOOL v BIT(1) v TINYINT(1) - 09-30-2010 , 07:16 PM



On 9/30/2010 4:51 PM, Sgt Snorkel wrote:
Quote:
On Thu, 30 Sep 2010 15:37:17 -0400, Jerry Stuckle
jstucklex (AT) attglobal (DOT) net> wrote:

On 9/30/2010 10:51 AM, Sgt Snorkel wrote:
If I create a table with 32 columns each declared as BOOL, will the
data be stored as bits (32 bits = 4 bytes) or an individual bytes?
Will each row be 4 bytes or 32?


According to the MySQL website (10.1.1)

http://dev.mysql.com/doc/refman/5.0/...-overview.html

BOOL = BIT(1) = TINYINT(1)

And according 10.2, TINYINT is 1 byte. It also says:

"As of MySQL 5.0.3, a BIT data type is available for storing bit-field
values. (Before 5.0.3, MySQL interprets BIT as TINYINT(1).)"

Thanks

32 BOOL columns is not the same as one BIT column with 32 values. 32
columns will take 32 TINYINT's.

That's what I thought, thanks.

But why are you prematurely optimizing? Even if you have 1M rows, the
difference is only 31 MB. Design the database properly.

Because I need to send it from the server to the client over the
Internet. A 32:1 reduction in size is a 32:1 reduction in wait time.
No, it isn't. You'll have more than that in protocol overhead.

You're prematurely optimizing.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #6  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: Datatypes: BOOL v BIT(1) v TINYINT(1) - 09-30-2010 , 07:17 PM



On 9/30/2010 5:10 PM, Sgt Snorkel wrote:
Quote:
On Thu, 30 Sep 2010 15:37:17 -0400, Jerry Stuckle
jstucklex (AT) attglobal (DOT) net> wrote:

On 9/30/2010 10:51 AM, Sgt Snorkel wrote:
If I create a table with 32 columns each declared as BOOL, will the
data be stored as bits (32 bits = 4 bytes) or an individual bytes?
Will each row be 4 bytes or 32?


According to the MySQL website (10.1.1)

http://dev.mysql.com/doc/refman/5.0/...-overview.html

BOOL = BIT(1) = TINYINT(1)

And according 10.2, TINYINT is 1 byte. It also says:

"As of MySQL 5.0.3, a BIT data type is available for storing bit-field
values. (Before 5.0.3, MySQL interprets BIT as TINYINT(1).)"

Thanks

32 BOOL columns is not the same as one BIT column with 32 values. 32
columns will take 32 TINYINT's.

But why are you prematurely optimizing? Even if you have 1M rows, the
difference is only 31 MB. Design the database properly.

PS: Isn't the difference actually 28MB?

PPS: I'm surprised that the database system doesn't pack 32 BOOL
columns into 4 physical bytes so I don't have to worry about it.
True. But why should the database pack them? That's not what you told
it to do. However, it's immaterial - you should not be shipping the
database files, anyway. You should be taking a dump of the database and
ship it.

But again - you are prematurely optimizing. Design your database correctly.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #7  
Old   
Sgt Snorkel
 
Posts: n/a

Default Re: Datatypes: BOOL v BIT(1) v TINYINT(1) - 09-30-2010 , 07:55 PM



On Thu, 30 Sep 2010 20:17:38 -0400, Jerry Stuckle
<jstucklex (AT) attglobal (DOT) net> wrote:

Quote:
On 9/30/2010 5:10 PM, Sgt Snorkel wrote:
On Thu, 30 Sep 2010 15:37:17 -0400, Jerry Stuckle
jstucklex (AT) attglobal (DOT) net> wrote:

On 9/30/2010 10:51 AM, Sgt Snorkel wrote:
If I create a table with 32 columns each declared as BOOL, will the
data be stored as bits (32 bits = 4 bytes) or an individual bytes?
Will each row be 4 bytes or 32?


According to the MySQL website (10.1.1)

http://dev.mysql.com/doc/refman/5.0/...-overview.html

BOOL = BIT(1) = TINYINT(1)

And according 10.2, TINYINT is 1 byte. It also says:

"As of MySQL 5.0.3, a BIT data type is available for storing bit-field
values. (Before 5.0.3, MySQL interprets BIT as TINYINT(1).)"

Thanks

32 BOOL columns is not the same as one BIT column with 32 values. 32
columns will take 32 TINYINT's.

But why are you prematurely optimizing? Even if you have 1M rows, the
difference is only 31 MB. Design the database properly.

PS: Isn't the difference actually 28MB?

PPS: I'm surprised that the database system doesn't pack 32 BOOL
columns into 4 physical bytes so I don't have to worry about it.

True. But why should the database pack them? That's not what you told
it to do. However, it's immaterial - you should not be shipping the
database files, anyway. You should be taking a dump of the database and
ship it.

But again - you are prematurely optimizing. Design your database correctly.
Do you ever get tired of knowing what other people need better than
they do themselves? Obviously not.

Reply With Quote
  #8  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: Datatypes: BOOL v BIT(1) v TINYINT(1) - 09-30-2010 , 09:12 PM



On 9/30/2010 8:55 PM, Sgt Snorkel wrote:
Quote:
On Thu, 30 Sep 2010 20:17:38 -0400, Jerry Stuckle
jstucklex (AT) attglobal (DOT) net> wrote:

On 9/30/2010 5:10 PM, Sgt Snorkel wrote:
On Thu, 30 Sep 2010 15:37:17 -0400, Jerry Stuckle
jstucklex (AT) attglobal (DOT) net> wrote:

On 9/30/2010 10:51 AM, Sgt Snorkel wrote:
If I create a table with 32 columns each declared as BOOL, will the
data be stored as bits (32 bits = 4 bytes) or an individual bytes?
Will each row be 4 bytes or 32?


According to the MySQL website (10.1.1)

http://dev.mysql.com/doc/refman/5.0/...-overview.html

BOOL = BIT(1) = TINYINT(1)

And according 10.2, TINYINT is 1 byte. It also says:

"As of MySQL 5.0.3, a BIT data type is available for storing bit-field
values. (Before 5.0.3, MySQL interprets BIT as TINYINT(1).)"

Thanks

32 BOOL columns is not the same as one BIT column with 32 values. 32
columns will take 32 TINYINT's.

But why are you prematurely optimizing? Even if you have 1M rows, the
difference is only 31 MB. Design the database properly.

PS: Isn't the difference actually 28MB?

PPS: I'm surprised that the database system doesn't pack 32 BOOL
columns into 4 physical bytes so I don't have to worry about it.

True. But why should the database pack them? That's not what you told
it to do. However, it's immaterial - you should not be shipping the
database files, anyway. You should be taking a dump of the database and
ship it.

But again - you are prematurely optimizing. Design your database correctly.

Do you ever get tired of knowing what other people need better than
they do themselves? Obviously not.
Nope. But transferring the database files themselves is not supported
for a large number of reasons. Export and ship is.

If you don't want an answer, don't ask a question. And don't come
crying back here when you find your data has been corrupted.

And yes, you are prematurely optimizing. I've seen your type too many
times over the 40+ years I've been programming.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #9  
Old   
Sgt Snorkel
 
Posts: n/a

Default Re: Datatypes: BOOL v BIT(1) v TINYINT(1) - 09-30-2010 , 10:10 PM



On Thu, 30 Sep 2010 22:12:59 -0400, Jerry Stuckle
<jstucklex (AT) attglobal (DOT) net> wrote:

Quote:
On 9/30/2010 8:55 PM, Sgt Snorkel wrote:
On Thu, 30 Sep 2010 20:17:38 -0400, Jerry Stuckle
jstucklex (AT) attglobal (DOT) net> wrote:

On 9/30/2010 5:10 PM, Sgt Snorkel wrote:
On Thu, 30 Sep 2010 15:37:17 -0400, Jerry Stuckle
jstucklex (AT) attglobal (DOT) net> wrote:

On 9/30/2010 10:51 AM, Sgt Snorkel wrote:
If I create a table with 32 columns each declared as BOOL, will the
data be stored as bits (32 bits = 4 bytes) or an individual bytes?
Will each row be 4 bytes or 32?


According to the MySQL website (10.1.1)

http://dev.mysql.com/doc/refman/5.0/...-overview.html

BOOL = BIT(1) = TINYINT(1)

And according 10.2, TINYINT is 1 byte. It also says:

"As of MySQL 5.0.3, a BIT data type is available for storing bit-field
values. (Before 5.0.3, MySQL interprets BIT as TINYINT(1).)"

Thanks

32 BOOL columns is not the same as one BIT column with 32 values. 32
columns will take 32 TINYINT's.

But why are you prematurely optimizing? Even if you have 1M rows, the
difference is only 31 MB. Design the database properly.

PS: Isn't the difference actually 28MB?

PPS: I'm surprised that the database system doesn't pack 32 BOOL
columns into 4 physical bytes so I don't have to worry about it.

True. But why should the database pack them? That's not what you told
it to do. However, it's immaterial - you should not be shipping the
database files, anyway. You should be taking a dump of the database and
ship it.

But again - you are prematurely optimizing. Design your database correctly.

Do you ever get tired of knowing what other people need better than
they do themselves? Obviously not.

Nope. But transferring the database files themselves is not supported
for a large number of reasons. Export and ship is.

If you don't want an answer, don't ask a question. And don't come
crying back here when you find your data has been corrupted.

And yes, you are prematurely optimizing. I've seen your type too many
times over the 40+ years I've been programming.
Ever heard of the One Note Samba?

Reply With Quote
  #10  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: Datatypes: BOOL v BIT(1) v TINYINT(1) - 10-01-2010 , 06:52 AM



On 9/30/2010 11:10 PM, Sgt Snorkel wrote:
Quote:
On Thu, 30 Sep 2010 22:12:59 -0400, Jerry Stuckle
jstucklex (AT) attglobal (DOT) net> wrote:

On 9/30/2010 8:55 PM, Sgt Snorkel wrote:
On Thu, 30 Sep 2010 20:17:38 -0400, Jerry Stuckle
jstucklex (AT) attglobal (DOT) net> wrote:

On 9/30/2010 5:10 PM, Sgt Snorkel wrote:
On Thu, 30 Sep 2010 15:37:17 -0400, Jerry Stuckle
jstucklex (AT) attglobal (DOT) net> wrote:

On 9/30/2010 10:51 AM, Sgt Snorkel wrote:
If I create a table with 32 columns each declared as BOOL, will the
data be stored as bits (32 bits = 4 bytes) or an individual bytes?
Will each row be 4 bytes or 32?


According to the MySQL website (10.1.1)

http://dev.mysql.com/doc/refman/5.0/...-overview.html

BOOL = BIT(1) = TINYINT(1)

And according 10.2, TINYINT is 1 byte. It also says:

"As of MySQL 5.0.3, a BIT data type is available for storing bit-field
values. (Before 5.0.3, MySQL interprets BIT as TINYINT(1).)"

Thanks

32 BOOL columns is not the same as one BIT column with 32 values. 32
columns will take 32 TINYINT's.

But why are you prematurely optimizing? Even if you have 1M rows, the
difference is only 31 MB. Design the database properly.

PS: Isn't the difference actually 28MB?

PPS: I'm surprised that the database system doesn't pack 32 BOOL
columns into 4 physical bytes so I don't have to worry about it.

True. But why should the database pack them? That's not what you told
it to do. However, it's immaterial - you should not be shipping the
database files, anyway. You should be taking a dump of the database and
ship it.

But again - you are prematurely optimizing. Design your database correctly.

Do you ever get tired of knowing what other people need better than
they do themselves? Obviously not.

Nope. But transferring the database files themselves is not supported
for a large number of reasons. Export and ship is.

If you don't want an answer, don't ask a question. And don't come
crying back here when you find your data has been corrupted.

And yes, you are prematurely optimizing. I've seen your type too many
times over the 40+ years I've been programming.

Ever heard of the One Note Samba?
Ever heard of "clueless idiot who argues just to make himself look even
more stoopid than he is?". That describes you to a T.

I play the note because it is the right one. You are prematurely
optimizing. And copying the files from one system to another is not
supported, for many reasons. The correct way to do it is to backup the
database and ship the backup.

Otherwise, don't come back here crying when your data becomes corrupted.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.