예제 #1
0
 protected static function _gather_stat($table, $column, $value, $max_size = -1)
 {
     global $DB;
     $table = trim($table, "`");
     $column = trim($column, "`");
     $arStat = CPerfQueryStat::GatherTableStat($table);
     if ($max_size < 0 || $arStat["TABLE_SIZE"] < $max_size) {
         $table = preg_replace("/[^A-Za-z0-9%_]+/i", "", $table);
         $column = preg_replace("/[^A-Za-z0-9%_]+/i", "", $column);
         if (isset($value)) {
             $rs = $DB->Query($d = "\n\t\t\t\t\tselect count(1) CNT\n\t\t\t\t\tfrom " . $DB->ForSQL($table) . "\n\t\t\t\t\twhere " . $DB->ForSQL($column) . " = '" . $DB->ForSQL($value) . "'\n\t\t\t\t");
         } else {
             $rs = $DB->Query($d = "\n\t\t\t\t\tselect count(distinct " . $DB->ForSQL($column) . ") CNT\n\t\t\t\t\tfrom " . $DB->ForSQL($table) . "\n\t\t\t\t");
         }
         if ($ar = $rs->Fetch()) {
             $DB->Add("b_perf_tab_column_stat", array("TABLE_NAME" => $table, "COLUMN_NAME" => $column, "TABLE_ROWS" => $arStat["TABLE_ROWS"], "COLUMN_ROWS" => $ar["CNT"], "VALUE" => isset($value) ? $value : false));
         }
         return true;
     } else {
         return false;
     }
 }
예제 #2
0
	</tr>
	<tr>
		<td align="right" class="adm-detail-valign-top">
			<table class="internal">
			<tr class="heading">
				<td><?php 
echo GetMessage("PERFMON_IDETAIL_TABLE_COLUMN");
?>
</td>
				<td><?php 
echo GetMessage("PERFMON_IDETAIL_COLUMN_DATA_TYPE");
?>
</td>
			</tr>
			<?php 
foreach (CPerfQueryStat::GetTableColumns($arSuggest["TABLE_NAME"]) as $column_name => $arColumn) {
    $b = in_array($column_name, $arColumns);
    ?>
			<tr>
				<td><?php 
    echo ($b ? "<b>" : "") . htmlspecialcharsex($column_name) . ($b ? "</b>" : "");
    ?>
</td>
				<td><?php 
    echo htmlspecialcharsex($arColumn["Type"]);
    ?>
</td>
			</tr>
			<?php 
}
?>
예제 #3
0
                                         $missed_keys = $q->suggest_index($alias);
                                         if ($missed_keys) {
                                             $arMissedKeys = array_merge($arMissedKeys, $missed_keys);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if (!empty($arMissedKeys)) {
                     foreach (array_unique($arMissedKeys) as $suggest) {
                         list($alias, $table, $columns) = explode(":", $suggest);
                         if (!CPerfQueryStat::IsBanned($table, $columns) && !CPerfomanceIndexComplete::IsBanned($table, $columns)) {
                             if (CPerfQueryStat::GatherExpressStat($table, $columns, $q) && !CPerfQueryStat::IsSelective($table, $columns, $q)) {
                                 CPerfQueryStat::Ban($table, $columns);
                             } else {
                                 CPerfomanceIndexSuggest::Add(array("TABLE_NAME" => $table, "TABLE_ALIAS" => $alias, "COLUMN_NAMES" => $columns, "SQL_TEXT" => $arSQL["SQL_TEXT"], "SQL_MD5" => $sql_md5, "SQL_COUNT" => 0, "SQL_TIME" => 0, "SQL_EXPLAIN" => serialize($arExplain)));
                             }
                         }
                     }
                     CPerfomanceIndexSuggest::UpdateStat($sql_md5, 1, $arSQL["QUERY_TIME"], $arSQL["ID"]);
                 }
             }
         } else {
             CPerfomanceIndexSuggest::UpdateStat($sql_md5, 1, $arSQL["QUERY_TIME"], $arSQL["ID"]);
         }
         $last_id = $arSQL["ID"];
     }
 }
 break;