BIT(1) vs ENUM('unknown', 'male', 'female') in MySQL
In per开发者_如何学运维formance 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
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.
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.
精彩评论