Ejemplo n.º 1
0
 public function check()
 {
     $return = array();
     $status = helper_dbtool::gettablestatus(DB::table('forum_thread'), false);
     if ($status && $status['Data_length'] > 400 * 1048576) {
         $return = array('status' => '1', 'type' => 'header', 'lang' => lang('optimizer', 'optimizer_thread_need_optimizer'));
     } else {
         $return = array('status' => '0', 'type' => 'header', 'lang' => lang('optimizer', 'optimizer_thread_no_need'));
     }
     return $return;
 }
 public function split_check($wheresql)
 {
     $status = helper_dbtool::gettablestatus(DB::table($this->_table), false);
     if ($status && $status['Data_length'] > 100 * 1048576) {
         //400 * 1048576
         if ($moverows = DB::result_first('SELECT COUNT(*) FROM %t WHERE ' . $wheresql, array($this->_table))) {
             $status['Move_rows'] = $moverows;
             $this->tablestatus = $status;
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 3
0
 public function check()
 {
     global $_G;
     loadcache('posttable_info');
     $count = 0;
     $posttableids = array_keys($_G['cache']['posttable_info']);
     foreach ($posttableids as $id) {
         $table = empty($id) ? 'forum_post' : (is_numeric($id) ? 'forum_post_' . $id : $id);
         $status = helper_dbtool::gettablestatus(DB::table($table), false);
         if ($status && $status['Data_length'] > 400 * 1048576) {
             $count++;
         }
     }
     if ($count) {
         $return = array('status' => '1', 'type' => 'header', 'lang' => lang('optimizer', 'optimizer_post_need_split', array('count' => $count)));
     } else {
         $return = array('status' => '0', 'type' => 'header', 'lang' => lang('optimizer', 'optimizer_post_not_need'));
     }
     return $return;
 }
Ejemplo n.º 4
0
function movedate($tids)
{
    global $sourcesize, $tableid, $movesize, $targettableid, $hash, $tableindex, $threadtableids, $fieldstr, $fromtableid, $posttable_info;
    $fromtable = getposttable($fromtableid, true);
    C::t('forum_post')->move_table($targettableid, $fieldstr, $fromtable, $tids);
    if (DB::errno()) {
        C::t('forum_post')->delete_by_tid($targettableid, $tids);
    } else {
        foreach ($threadtableids as $threadtableid) {
            $affected_rows = C::t('forum_thread')->update($tids, array('posttableid' => $targettableid), false, false, $threadtableid);
            if ($affected_rows == count($tids)) {
                break;
            }
        }
        C::t('forum_post')->delete_by_tid($fromtableid, $tids);
    }
    $status = helper_dbtool::gettablestatus(getposttable($targettableid, true), false);
    $targetsize = $sourcesize + $movesize * 1048576;
    $nowdatasize = $targetsize - $status['Data_length'];
    if ($status['Data_length'] >= $targetsize) {
        cpmsg('postsplit_done', 'action=postsplit&operation=optimize&tableid=' . $fromtableid, 'form');
    }
    cpmsg('postsplit_doing', 'action=postsplit&operation=movepost&fromtable=' . $tableid . '&movesize=' . $movesize . '&targettable=' . $targettableid . '&hash=' . $hash . '&tindex=' . $tableindex, 'loadingform', array('datalength' => sizecount($status['Data_length']), 'nowdatalength' => sizecount($nowdatasize)));
}