[wp-hackers] Idea: Widgets as custom post types

Brian Layman bulk at thecodecave.com
Tue Mar 2 21:50:55 UTC 2010

I'm sorry but I think this is a horrible idea. Horrible enough to come out
of lurk for it..

Why would I want to store my 8-16 widgets in tables that, in one db I just
looked at, has 434,921 non-widget-related records? I don't think it makes

Yes, you can rationalize how everything is the same because it is all just
data, but that does not mean that it is simpler or cleaner. That's why I
regret any hand I may or may not have had current terms table structure. 

We are setting ourselves up to view everything from a million miles above
and all we will have accomplished is the migration of tables names into
various more difficult to query "type" fields. We are reconstructing the
divisions we already but we are doing it using data rather than structure.

A smaller list of tables is equal to a "clean" database design. Clean is
when the database server can grab your data by searching through as few
tightly indexed records as possible.  "Clean" is not having a "term" that
you have to look at term_taxonomy in order to find if you are dealing with a
tag or category and then with the right taxonomy ID grabbing the list of
relationships for that taxonomy ID and then "knowing" that what you are
dealing with is a post (or not) because of the implied knowledge in the
taxonomy definition and then using that list of "object IDs" to query the
post table and hopefully find the two posts you've tagged with the word
"simplistic". That is not clean.

I'm not a Normalization Nazi. Sometimes it is irrational to make a separate
table when all of the data is going to be the same. I don't want to store
drafts and revisions and published posts in separate tables or anything
silly like that, but I really think we are going to far in grouping things
and it is hurting the performance of WordPress sites. 

I really really wish we could have things like meta_key be a unique value so
that when I supply site_blog_meta_key the database is looking at one
specific unique value that it returns at near the speed of light. We're way
past that point, but maybe we can stop adding even more generalization.

Anyway that's my 5 cents.

- Brian Layman

-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of scribu
Sent: Tuesday, March 02, 2010 3:07 PM
To: wp-hackers
Subject: [wp-hackers] Idea: Widgets as custom post types

Currently, each widget type has a an associated row in the wp_options table,
where all instances of itself are stored.

Taking example from the nav menus in WP 3.0, why not store each widget in
the wp_posts table, with a post_type of 'widget' ?


wp-hackers mailing list
wp-hackers at lists.automattic.com

More information about the wp-hackers mailing list