[wp-hackers] post_status and post_type

Jeff Minard jeff at jrm.cc
Thu Feb 9 16:23:26 GMT 2006


Owen Winkler wrote:
> Why is post_type a varchar(100) and not an enum('post','page', 
> 'attachment')?  Wouldn't that be faster?

Yes, enums are faster.

1) enums are a psuedo look-up table. MySQL stores a smallint val for 
each enum and uses that when doing lookups. It's kind of like having a 
lookup table and doing a join across them, except that mysql does it all 
for you.

2) this means enums are compared, internally, as ints -- a much faster 
query for mysql

3) it also means smaller storage space

4) it, consequently, means smaller index size

So, yes, enums *are* faster -- but by how much at the cost of locking 
the "post types" down, is the real question. Probably not enough for the 
vast majority of wordpress installs.

(Flip side of this arguement is: authors, have your plugins modify the 
DB upon run to check for the enum def, if not there modify to add it. 
SUPER problematic, but possible.)


I like the ideas stated later in the thread of leaving it a varchar to 
allow others to make up their own post types. The only complication this 
involves is whether or not WP would edit non-standard post_types or not. 
Lot's of queries would be needing some updating to make sure they're 
only pulling "post" post_types and so forth.

Also...

Mark Jaquith wrote:
> What about post_status="future"?  That still on the table?

+145,000,000

As otherwise stated, death to all "< $now" clauses.

Jeff


More information about the wp-hackers mailing list