Финансовая поддержка VPS, бесплатные дополнения и docs Донаты оплачивают сервер и двигают бесплатные дополнения MODX и документацию. Поддержать

Всего 126 145 комментариев

Евгений Борисов
Евгений Борисов
1) modx_tickets_threads индекс к deleted
2) modx_tickets_votes индекс к class
3) modx_tickets_comments индекс к published, createdby
4) modx_site_content индекс к deleted

Без внедрения в код больше ничего не сделать. В идеале конечно разбить запрос на части. Я думаю у василия это уже в планах, т.к. разговор у нас с ним на эту тему был;-)
А вообще, после простановки этих индексов должен чутка быстрее работать не только листинг тикетов. Кстати, если не сложно покажите SHOW PROFILE и EXPLAIN запроса после простановки индексов.
Андрей
Андрей
SELECT SQL_CALC_FOUND_ROWS 
`Ticket`.`id`, `Ticket`.`type`, `Ticket`.`contentType`, `Ticket`.`pagetitle`, `Ticket`.`longtitle`, `Ticket`.`description`, `Ticket`.`alias`, `Ticket`.`link_attributes`, `Ticket`.`published`, `Ticket`.`pub_date`, `Ticket`.`unpub_date`, `Ticket`.`parent`, `Ticket`.`isfolder`, `Ticket`.`introtext`, `Ticket`.`richtext`, `Ticket`.`template`, `Ticket`.`menuindex`, `Ticket`.`searchable`, `Ticket`.`cacheable`, `Ticket`.`createdby`, `Ticket`.`createdon`, `Ticket`.`editedby`, `Ticket`.`editedon`, `Ticket`.`deleted`, `Ticket`.`deletedon`, `Ticket`.`deletedby`, `Ticket`.`publishedon`, `Ticket`.`publishedby`, `Ticket`.`menutitle`, `Ticket`.`donthit`, `Ticket`.`privateweb`, `Ticket`.`privatemgr`, `Ticket`.`content_dispo`, `Ticket`.`hidemenu`, `Ticket`.`class_key`, `Ticket`.`context_key`, `Ticket`.`content_type`, `Ticket`.`uri`, `Ticket`.`uri_override`, `Ticket`.`hide_children_in_tree`, `Ticket`.`show_in_tree`, `Ticket`.`properties`,
`Section`.`id` AS `section.id`, `Section`.`type` AS `section.type`, `Section`.`contentType` AS `section.contentType`, `Section`.`pagetitle` AS `section.pagetitle`, `Section`.`longtitle` AS `section.longtitle`, `Section`.`description` AS `section.description`, `Section`.`alias` AS `section.alias`, `Section`.`link_attributes` AS `section.link_attributes`, `Section`.`published` AS `section.published`, `Section`.`pub_date` AS `section.pub_date`, `Section`.`unpub_date` AS `section.unpub_date`, `Section`.`parent` AS `section.parent`, `Section`.`isfolder` AS `section.isfolder`, `Section`.`introtext` AS `section.introtext`, `Section`.`richtext` AS `section.richtext`, `Section`.`template` AS `section.template`, `Section`.`menuindex` AS `section.menuindex`, `Section`.`searchable` AS `section.searchable`, `Section`.`cacheable` AS `section.cacheable`, `Section`.`createdby` AS `section.createdby`, `Section`.`createdon` AS `section.createdon`, `Section`.`editedby` AS `section.editedby`, `Section`.`editedon` AS `section.editedon`, `Section`.`deleted` AS `section.deleted`, `Section`.`deletedon` AS `section.deletedon`, `Section`.`deletedby` AS `section.deletedby`, `Section`.`publishedon` AS `section.publishedon`, `Section`.`publishedby` AS `section.publishedby`, `Section`.`menutitle` AS `section.menutitle`, `Section`.`donthit` AS `section.donthit`, `Section`.`privateweb` AS `section.privateweb`, `Section`.`privatemgr` AS `section.privatemgr`, `Section`.`content_dispo` AS `section.content_dispo`, `Section`.`hidemenu` AS `section.hidemenu`, `Section`.`class_key` AS `section.class_key`, `Section`.`context_key` AS `section.context_key`, `Section`.`content_type` AS `section.content_type`, `Section`.`uri` AS `section.uri`, `Section`.`uri_override` AS `section.uri_override`, `Section`.`hide_children_in_tree` AS `section.hide_children_in_tree`, `Section`.`show_in_tree` AS `section.show_in_tree`, `Section`.`properties` AS `section.properties`, 
`User`.`username`, 
`Profile`.`internalKey`, `Profile`.`fullname`, `Profile`.`email`, `Profile`.`phone`, `Profile`.`mobilephone`, `Profile`.`blocked`, `Profile`.`blockeduntil`, `Profile`.`blockedafter`, `Profile`.`logincount`, `Profile`.`lastlogin`, `Profile`.`thislogin`, `Profile`.`failedlogincount`, `Profile`.`sessionid`, `Profile`.`dob`, `Profile`.`gender`, `Profile`.`address`, `Profile`.`country`, `Profile`.`city`, `Profile`.`state`, `Profile`.`zip`, `Profile`.`fax`, `Profile`.`photo`, `Profile`.`comment`, `Profile`.`website`, `Profile`.`extended`, 
SUM(`Vote`.`value`) AS `votes`, 
COUNT(DISTINCT `View`.`uid`) as `views`, 
`LastView`.`timestamp` as `new_comments`, 
COUNT(DISTINCT `Comment`.`id`) as `comments` 
FROM `modx_site_content` AS `Ticket` 
LEFT JOIN `modx_tickets_views` `View` ON Ticket.id=View.parent 
LEFT JOIN `modx_tickets_views` `LastView` ON Ticket.id=LastView.parent AND LastView.uid = 1 
LEFT JOIN `modx_tickets_votes` `Vote` ON Ticket.id=Vote.parent AND Vote.class='Ticket' 
LEFT JOIN `modx_tickets_threads` `Thread` ON Thread.resource=Ticket.id  AND Thread.closed=0 AND Thread.deleted=0 
LEFT JOIN `modx_tickets_comments` `Comment` ON Comment.thread=Thread.id AND Comment.published=1 
LEFT JOIN `modx_site_content` `Section` ON Section.id=Ticket.parent 
LEFT JOIN `modx_users` `User` ON User.id=Ticket.createdby 
LEFT JOIN `modx_user_attributes` `Profile` ON Profile.internalKey=User.id 
WHERE  ( `Ticket`.`class_key` = 'Ticket' AND `Ticket`.`published` = 1 AND `Ticket`.`deleted` = 0 )  
GROUP BY `Ticket`.`id` 
ORDER BY createdon DESC 
LIMIT 10
Василий Наумкин
Василий Наумкин
Василий Наумкин
Василий Наумкин
Мысль тут только одна: расставить дополнительных индексов (например, на deleted индекса нет) и написать свой собственный сниппет для вывода тикетов.

Убрать там все ненужные плюшки, лишние джоины и, возможно, разбить на несколько запросов, например отдельно считать кол-во комментов у тикета, или не считать вовсе.

Честно говоря, я вообще удивлен и очень рад, что 300 тысяч тикетов в принципе работают.
Дмитрий Иванов
Дмитрий Иванов
При Drag&Drop Firebug показывает такой ответ сервера:

Notice: Undefined index: HTTP_CONTENT_LENGTH in G:\xampp 1.8.2\xampp\htdocs\my_site\core\components\minishop2\processors\mgr\gallery\upload.class.php on line 103
{«success»:true,«message»:"\/my_site\/assets\/images\/products\/19\/48x48\/5a60c9891b527cd509ca0b5fee310376.jpg",«total»:0,«data»:[],«object»:[]}

Дело происходит на локальном сервере XAMPP 1.8.2

Вот код в классе upload.class.php:
if (!empty($stream)) {
			return array(
				'name' => $name
				,'stream' => $stream
				,'size' => $_SERVER['HTTP_CONTENT_LENGTH']  // 103 строка
			);
		}
		else {
			return false;
		}
Дмитрий Иванов
Дмитрий Иванов
Та же беда. При загрузке через кнопку «Выбрать файлы» в статусе загрузки написано «Ошибка», но изображения нормально создаются.
Мне бы было безразлично, да заказчика печалить не хочется. Не понимаю где копать — Firebug никаких POST, GET запросов не показывает, чтобы проследить куда уходят данные и что возвращают. Видимо, потому что Flash.
Через Drag&Drop тоже статус «Ошибка». Вначале вроде небыло.
Андрей
Андрей
Василий, внес твои изменения — все по прежнему.
Начал копать дальше. Выполнил запрос из mysql-редактора.
Всплыло вот что. Проблема в самом mysql — долго выполняется сброс данных и их сортировка.

EXPLAIN запроса


Профайлер запроса


Есть у кого-нибудь какие либо мысли?
Василий Наумкин
Василий Наумкин
311 000 тикетов? Фигасе.

Это скорее всего связано с тем, что там криво написана выборка по parents c depth — по карте ресурсов всегда получаются id потомков и включаются в запрос. А карта у тебя ооочень большая.

В MS2 уже поправил, попробуй изменить getTickets так:
else {
	// Filter by parents
	if (empty($parents) && $parents != '0') {$parents = $modx->resource->id;}
	if (!empty($parents) && $parents > 0){
		$pids = array_map('trim', explode(',', $parents));
		$parents = $pids;
		if (!empty($depth) && $depth > 0) {
			foreach ($pids as $v) {
				if (!is_numeric($v)) {continue;}
				$parents = array_merge($parents, $modx->getChildIds($v, $depth));
			}
		}
		if (!empty($parents)) {
			$where['parent:IN'] = $parents;
		}
	}
}

Ну а после этого вызывай getTickets с параметром &depth=0. Должно помочь.