[wp-hackers] post_status and post_type

David Chait davebytes at comcast.net
Thu Feb 9 15:43:38 GMT 2006

I can give a personal opinion on why I'd prefer it as-is.  While enums may 
be faster, varchars are extensible on-the-fly (i.e. plugins).  It was a pain 
when I found comment tagging as an enum with ('0','1','spam') -- which means 
my anti-spam plugin can't use the existing moderation field for tagging 
'potential spam' in grades without a secondary table.  Maybe I might come up 
with a plugin that manages a new post type, new content type.  I find 
varchars useful for more open expansion, while enums are good if you really 
have a fixed field and want the code and db to be more readable ('string' 
rathing than 'index').  Of course, varchars are just as readable. ;)  It's 
that an index field (say 1-3) is less readable than an enum 

I would assume by the nature of an enum it should be faster -- there is 
still some kind of conversion going on matching input in a query to the enum 
'slots' and converting to the corresponding index then doing the 
select/insert, versus no conversion just a string select/insert.  If it's 
really a numeric field under the covers, should be somewhat faster -- though 
string compares on exact matches can be pretty fast (4 chars at a time on a 
32-bit system, assuming no hash or anything to further accelerate).

Anyhow, I'd like to see more things pop out of enums unless critically 
needed to prevent coding errors (which could also be done by defining an 
array of possible values in the code, and allowing plugins to 'add' 
potential values to match, then doing a sanity-compare against the array as 
needed... slower, but infinitely extensible without changing the DB schema).


----- Original Message ----- 
From: "Owen Winkler" <ringmaster at midnightcircus.com>
To: <wp-hackers at lists.automattic.com>
Sent: Thursday, February 09, 2006 9:18 AM
Subject: Re: [wp-hackers] post_status and post_type

| Ryan Boren wrote:
| > Behold the changeset of destruction.
| >
| > http://trac.wordpress.org/changeset/3510
| >
| Curious on this one point:
| Why is post_type a varchar(100) and not an enum('post','page',
| 'attachment')?  Wouldn't that be faster? 

More information about the wp-hackers mailing list