yoderek wrote:
> Which would be the more optimzed way to store a
> boolean, TINYINT(1) or ENUM( 'true' , 'false')?
> It seems that when storing an enum w/ two settings
> should only take up one bit, 0 or 1, but would
> spend more time looking up the enums in the
> beginning of the query. tinyint(1) however would
> take up 4 bits assuming it ranged 0-9. So it seems
> if you just wanted to fetch the value, tinyint(1)
> would be faster, but if you are searching through
> lots of records enum('true','false') would be
> faster. Do you concur??
TINYINT takes up 1 byte (8 bits) of storage, regardless of whether only 0 and 1 are stored.
ENUM takes up 1 byte of storage, if < 256 elements, 2 bytes of storage for up to 65,535 elements.
You can also check out the BIT data type, which is, I think, what you are looking for:
http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html
http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
http://dev.mysql.com/doc/refman/5.0/en/bit-field-values.html
Jay Pipes
Community Relations Manager, North America, MySQL Inc.
Got Cluster?
http://www.mysql.com/cluster
Personal:
http://jpipes.com