• Resolved rwhaun

    (@rwhaun)


    I’ve been running into CPU throttling issues on my server. When I analyze my mysql_slow_queries logs I find dozens and dozens of calls by Bad Behavior to “CREATE TABLE IF NOT EXISTS…” (via bb2_table_structure() in bad-behavior-mysql.php).

    While the “IF NOT EXISTS” condition keeps it from creating the table over and over, it is still using system resources by checking every time a visitor hits my site. In the mediawiki version of Bad Behavior there is a CONSTANT (BB2_NO_CREATE) that can be set to tell it to skip the CREATE TABLE call.

    Why is there no CONSTANT for the WordPress version and how can I prevent CREATE TABLE from being called needlessly over and over? We only need to CREATE TABLE once when the plugin is installed.

    http://wordpress.org/extend/plugins/bad-behavior/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter rwhaun

    (@rwhaun)

    While looking around in bad-behavior-wordpress.php I noticed lines 184-193:

    // FIXME: figure out what's wrong on 2.0 that this doesn't work
    // register_activation_hook(__FILE__, 'bb2_install');
    //add_action('activate_bb2/bad-behavior-wordpress.php', 'bb2_install');
    add_action('wp_head', 'bb2_insert_head');
    add_action('wp_footer', 'bb2_insert_stats');
    add_action('wp_insert_comment', 'bb2_capture_spam', 99, 2);
    
    // Calls inward to Bad Behavor itself.
    require_once(BB2_CWD . "/bad-behavior/core.inc.php");
    bb2_install();	// FIXME: see above

    It looks like the developer knows there is an issue with only calling the CREATE TABLE script on plugin activation via bb2_install(). However, it isn’t acceptable to simply try and create table over and over. Plus, we should have been warned – trying to CREATE the Bad Behavior table every time is a ridiculous waste of resources.

    For now, I’ve commented out line 193: bb2_install();

    I hope the developer rolls out a fix or at least notifies folks of this issue.

    Plugin Author error

    (@error)

    Yep it’s messy.

    It’s also getting rewritten from scratch shortly, so it should no longer be an issue soon.

    That said, CREATE TABLE IF NOT EXISTS is quite trivial, so if you’re seeing this in your MySQL slow query log, there is something horribly wrong with your server’s configuration (and it isn’t this). You may want to get an expert to look at it, if the usual MySQL tuning steps don’t help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘CREATE TABLE called over and over and over’ is closed to new replies.