[wp-hackers] Meta tables: Take 5

Otto otto at ottodestruct.com
Fri Jul 24 17:03:33 UTC 2009

On Fri, Jul 24, 2009 at 5:21 AM, scribu<scribu at gmail.com> wrote:
> - WP core shouldn't create tables that it doesn't use. The same principle is
> applied to bundled javascript and php classes.

I agree with this. However, there's several things that the core could
be putting into a comment meta table. A lot of the lesser used columns
could be moved to meta data and this speed up comments retrieval
(probably by a trivial amount, but hey).

Check out the comments table schema:

  comment_ID bigint(20) unsigned NOT NULL auto_increment,
  comment_post_ID bigint(20) unsigned NOT NULL default '0',
  comment_author tinytext NOT NULL,
  comment_author_email varchar(100) NOT NULL default '',
  comment_author_url varchar(200) NOT NULL default '',
  comment_author_IP varchar(100) NOT NULL default '',
  comment_date datetime NOT NULL default '0000-00-00 00:00:00',
  comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
  comment_content text NOT NULL,
  comment_karma int(11) NOT NULL default '0',
  comment_approved varchar(20) NOT NULL default '1',
  comment_agent varchar(255) NOT NULL default '',
  comment_type varchar(20) NOT NULL default '',
  comment_parent bigint(20) unsigned NOT NULL default '0',
  user_id bigint(20) unsigned NOT NULL default '0',

Is the author IP critical information that is used a lot? How about
the agent? And WTF is karma?

Yes, we need comment meta for plugins. But we could just as easily
move some of this stuff in there too, perhaps even expanding the core
functionality a bit in the process.


More information about the wp-hackers mailing list