Whatever I set in config for "Log OPTIMIZE queries", my logs are full of db optimization logs.
This happens on some sites, while other behave correctly (multi site install - same code, separate databese)
Any clue?

thanks for help

Comments

tjferre’s picture

Version: 6.x-1.2 » 7.x-1.1
Component: Documentation » Code
Status: Active » Needs review

I have this issue as well, here this is my fix for it. I did make some changes to it as you can see below. Now checking the box will create a watchdog entry for every table that is optimized. Not checking the box will display only one watchdog entry containing all of the tables that were optimized. I didn't want all the entries cluttering up my db log, but I think it is important to have at least one entry noting the optimization occurred.

If you have any questions please let me know.

TJ

Original - line 173 in .module

<?php
        // Return to the previously set database.
        db_set_active($previous);
        watchdog('db_maintenance', 'Optimized @table table in @db database.', array('@db' => $db_name, '@table' => $table_name), WATCHDOG_DEBUG);
      }

      if (variable_get('db_maintenance_log', 0)) {
        $tables = implode(', ', $config_tables);
        watchdog('db_maintenance', 'Optimized tables in @db database: @tables', array('@db' => $db_name, '@tables' => $tables), WATCHDOG_INFO);
      }
?>

New - line 173 in .module

<?php
             // Return to the previously set database.
        db_set_active($previous);
        
        //Log All Optimize Queries
		if (variable_get('db_maintenance_log') == 1) {
          watchdog('db_maintenance', 'Optimized @table table in @db database.', array('@db' => $db_name, '@table' => $table_name), WATCHDOG_DEBUG);
        }
      }
	  
	  //Log Optimization Occurred
	  if (variable_get('db_maintenance_log') == 0) { 
      	$tables = implode(', ', $config_tables);
	    watchdog('db_maintenance', 'Optimized tables in @db database: @tables', array('@db' => $db_name, '@tables' => $tables), WATCHDOG_INFO);
	  }
?>

I also changed the description & title in the admin settings. - line 202 in .module

<?php
 $form['db_maintenance_log'] = array(
    '#type' => 'checkbox',
    '#title' => 'Log All OPTIMIZE queries',
    '#default_value' => variable_get('db_maintenance_log', 0),
    '#description' => t('If enabled, a watchdog entry will be made each time a table is optimized.'),
  );
?>
deekayen’s picture

Status: Needs review » Closed (won't fix)

Each of those logging methods have different levels of severity. If you don't like seeing so much, filter out the DEBUG level ones.