Wiliam
Wiliam

Reputation: 3754

BIT(1) vs ENUM('unknown', 'male', 'female') in MySQL

In performance terms, what will be faster, use a BIT(1) NULL (null = unknown, 0 = male, 1 = female) or ENUM('unknown', 'male', 'female') NOT NULL DEFAULT 'unknown' in MySQL MyISAM?

Or this is considered micro-optimization?

[EDIT]

I think I'm going to use ENUM('male', 'female') DEFAULT NULL

Upvotes: 0

Views: 1439

Answers (2)

user188041
user188041

Reputation:

I consider this micro-optimization.

I would go for the ENUM option, because the meaning of all values is completely clear without reading documentation. The bit option is a bit vague.

Regarding performance, I seem to remember NULL is usually bad, but can't find references right now.

Upvotes: 1

Beth
Beth

Reputation: 4660

Yes, this is microoptimization. Performance will be dominated by other things, and anyway nullable fields take more space (for a null flag) so use the meaningful enumeration.

Upvotes: 4

Related Questions