Exemplo n.º 1
0
                                     foreach ($q->table_joins($arRes["table"]) as $alias => $join_columns) {
                                         $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"];
     }
 }
Exemplo n.º 2
0
									}
								}
							}
						}
						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),
										));