@viktorross

Ошибка в скрипте, почему главная страница грузится 15 секунд?

здравствуйте, подскажите пожалуйста в чем может быть проблема, главная страница грузится почти 15 секунд, при этом все остальные за несколько секунд, есть 3 ошибки в логе, возможно это связано как-то

1 ошибка и вторая:

[Fri Aug 02 12:47:51 2019] [warn] [client 178.154.171.24] mod_fcgid: stderr: PHP Notice: Undefined variable: join_users in /var/www/site/data/www/site.ru/classes/listings.php on line 1216
[Fri Aug 02 12:47:51 2019] [warn] [client 178.154.171.24] mod_fcgid: stderr: PHP Notice: Undefined variable: join_ext in /var/www/site/data/www/site.ru/classes/listings.php on line 1216
[Fri Aug 02 12:47:51 2019] [warn] [client 178.154.171.24] mod_fcgid: stderr: PHP Notice: Undefined variable: join_options in /var/www/site/data/www/site.ru/classes/listings.php on line 1216
[Fri Aug 02 12:47:51 2019] [warn] [client 178.154.171.24] mod_fcgid: stderr: PHP Notice: Undefined variable: join_pe in /var/www/site/data/www/site.ru/classes/listings.php on line 1217

// count(*) faster than count(val) **********
		$sql = "select count($count) 
		from ".TABLE_ADS."
		$join_pictures $join_users $join_ext $join_options $join_pe
		$q_join
		".$where.$locations_str;
		//echo $sql;
		$no_ads = $db->fetchRow($sql);

		return $no_ads;
	}


третья возможно никакого отношения не имеет к этому

// get listing data
		$listing_info = $db->fetchAssoc("select $title_field, ".TABLE_ADS.".$description_field, ".TABLE_ADS.".*,  ".TABLE_ADS.".`meta_description` as `meta_description`, ".TABLE_ADS.".`meta_keywords` as `meta_keywords`, ".TABLE_CATEGORIES.".`parent_id`, ".TABLE_CATEGORIES."_lang.`name` as `category_name`, ".TABLE_CATEGORIES."_lang.`meta_description` as `category_meta_description`, ".TABLE_CATEGORIES."_lang.`meta_keywords` as `category_meta_keywords`, ".TABLE_CATEGORIES."_lang.`page_title` as `category_title` $location_str from ".TABLE_ADS." left join ".TABLE_CATEGORIES."_lang on ".TABLE_ADS.".category_id=".TABLE_CATEGORIES."_lang.id left join ".TABLE_CATEGORIES." on ".TABLE_ADS.".category_id=".TABLE_CATEGORIES.".id where ".TABLE_ADS.".id='".$id."' and `lang_id`='$crt_lang';");

		foreach ($listing_info as $key=>$value) {
		
			$listing_info[$key] = preg_replace("/[{}]/","",$listing_info[$key]);
		
		}


первые 2 запроса используются на многих страницах, но 15 секунд грузится только главная страница..

версия php 5.6 подскажите пожалуйста что тут не так

вот еще скрипт

$join_pictures = '';
		if(strstr($where, TABLE_ADS_PICTURES)) 
			$join_pictures = "inner join ".TABLE_ADS_PICTURES." on ".TABLE_ADS.".id=".TABLE_ADS_PICTURES.".ad_id ";

		$join_users = '';
		if(strstr($where, TABLE_USERS)) 
			$join_users = "inner join ".TABLE_USERS." on ".TABLE_ADS.".user_id=".TABLE_USERS.".id ";

		global $config_table_prefix;
		$group="";

		if(strstr($where, $config_table_prefix."zip")) 
			$group = " group by ".TABLE_ADS.".id ";

		$join_slugs='';
		$str_slugs='';
		$where_slugs='';
		if($seo_settings['enable_mod_rewrite']) {
			$join_slugs="inner join ".TABLE_SLUGS." on ".TABLE_ADS.".id=".TABLE_SLUGS.".object_id";
			$str_slugs=", ".TABLE_SLUGS.".slug ";
			$where_slugs=" and ".TABLE_SLUGS.".`type`='listing'";
		}
		$str_index = "";
		if($this->use_index) $str_index = " use index ({$this->use_index}) ";

		$sql = "select distinct ".TABLE_ADS.".*$mlang_vars, ".TABLE_ADS.".id as adid, date_format(".TABLE_ADS.".`date_added`,'$date_format') as date_nice, date_format(".TABLE_ADS.".`date_expires`,'$date_format') as date_expires_nice, UNIX_TIMESTAMP(".TABLE_ADS.".`date_added`) as `time_added`, (".TABLE_ADS.".date_expires < '$timestamp' and ".TABLE_ADS.".date_expires!='0000-00-00 00:00:00' and ".TABLE_ADS.".active=0) as expired
		$str_slugs
		$q_vars 
		from ".TABLE_ADS." $str_index
		$q_join $join_pictures $join_cat $join_users
		$join_slugs
		 ".$where.$where_slugs." ".$order_by." ".$order_way." ";
		if($ads_per_page>0) $sql .= " limit ".$general_row.", ".$ads_per_page;
//	echo $sql."<br/><br/>";
		$arr = $db->fetchAssocList($sql);
//_print_r($arr);
		$i=0;
		$result=array();
		$pictures=new pictures();


$join_ext , $join_options и $join_pe почему-то нет нигде вообще
  • Вопрос задан
  • 124 просмотра
Пригласить эксперта
Ответы на вопрос 2
usdglander
@usdglander Куратор тега PHP
Yipee-ki-yay
Что то подсказывает мне что в таблице картинок нифига не настроены индексы.
Ответ написан
ThunderCat
@ThunderCat Куратор тега PHP
{PHP, MySql, HTML, JS, CSS} developer
боожечки, нежто тяжко расставить 5 таймеров и посмотреть сколько времени что выполняется? 2 минуты работы.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
YCLIENTS Москва
от 200 000 до 350 000 ₽
Ведисофт Екатеринбург
от 25 000 ₽
ИТЦ Аусферр Магнитогорск
от 100 000 до 160 000 ₽