I noticed this ticket in WordPress Trac – Change enum to varchar and went in to see if there is any heated discussion. The issue is around field types used in SQL scheme for WordPress tables. Certain fields, such post status employed ENUM type with a set of allowed values. The proposed change in the ticket is to convert them to VARCHAR type.
Why the change? Well, VARCHAR is just a text field. Anyone can put pretty much any string into it. It has more flexibility for plugin developers and future changes – no need to tweak the SQL scheme. ENUM on the other hand works a little bit faster.
Side note: I also thought that ENUM provides some extra data validation, assuming the ENUM field is set to NOT NULL, but it turns out this is not the case. If you insert a record with a value which is not in the list, the NULL is used.Â
The change has been approved, the patch was attached, and the world will see it in the next WordPress release. Once again, it has been proven that human time is much more valuable than machine time. Making it easier for plugin developers to extend and change the system has more value than that of a few extra CPU cycles to lookup in strings instead of numbers.
I’ve read some benchmark comparing with varchar and enum. They are not much differ. Because varchar if limited values like enum, get indexed by mysql! Thus infact using limited number of varchar behaves like enum.
But man forced mysql to use not the index, and the impact came. varchar got slower by 20 times.
Using enum over int fields is big achivement, like wise varchar is a heaven gift. But one should use carefully using joins, and must ask dba about query (using analyse or explain).