<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
					xmlns:content="http://purl.org/rss/1.0/modules/content/"
					xmlns:wfw="http://wellformedweb.org/CommentAPI/"
					xmlns:atom="http://www.w3.org/2005/Atom"
				  >
<channel>
<atom:link rel="self"  type="application/rss+xml"  href="http://rulinux.net/rss_from_sect_4_subsect_6_thread_38914"  />
<title>rulinux.net - Форум - Development - [mysql] перфомансы и погромисты</title>
<link>http://rulinux.net/</link>
<description><![CDATA[Портал о GNU/Linux и не только]]></description>
<image><title>rulinux.net - Форум - Development - [mysql] перфомансы и погромисты</title>
<link>http://rulinux.net/</link>
<url>http://rulinux.net/rss_icon.png</url>
</image>
<item>
<title>Re:[mysql] перфомансы и погромисты</title>
<link>https://rulinux.net/message.php?newsid=38914&amp;page=1#165574</link>
<guid>https://rulinux.net/message.php?newsid=38914&amp;page=1#165574</guid>
<pubDate>Thu, 21 Feb 2013 18:11:46 +0400</pubDate>
<description><![CDATA[<p>&gt; SELECT og.goods_sn num_iid, SUM(og.goods_number) AS goods_number FROM `ecs_taobaosruruorder_info` AS o, `ecs_taobaosruruorder_goods` AS og WHERE 1  GROUP BY og.goods_sn ORDER BY goods_number DESC;
<br><br>
Это декартово произведение?
<br><br>
&gt; Так и не понял, какого хрена не используется ни один индекс для талбицы ecs_taobaosruruorder_goods
<br><br>
Если нет условия выборки - то один хрен читать все строки. Любая БД сообразит что читать ещё и индексы - только преумножать IO без какой-либо пользы.
</p>]]></description>
</item>
<item>
<title>Re:[mysql] перфомансы и погромисты</title>
<link>https://rulinux.net/message.php?newsid=38914&amp;page=1#165553</link>
<guid>https://rulinux.net/message.php?newsid=38914&amp;page=1#165553</guid>
<pubDate>Thu, 21 Feb 2013 15:01:48 +0400</pubDate>
<description><![CDATA[<p>Мусколь просто ни хуя не понял чего от него хотел этот &quot;погромист&quot;, и по этому на всякий случай решил не включать индексы))) Я собственно тоже не понял, даже интересно зачем может понадобиться такой запрос))) </p>]]></description>
</item>
<item>
<title>[mysql] перфомансы и погромисты</title>
<link>https://rulinux.net/message.php?newsid=38914&amp;page=1#165550</link>
<guid>https://rulinux.net/message.php?newsid=38914&amp;page=1#165550</guid>
<pubDate>Thu, 21 Feb 2013 13:24:28 +0400</pubDate>
<description><![CDATA[<p>Есть у меня один клиент с магазином всякого-всякого.<br><br>Двиг магазина какой-то самописный, где хозяйничает у него свой погромист, который все это дело, соответственно погромирует.<br><br>И есть у него один презабавный запрос в мускуле (innodb), который любит забивать всю работу мускуля к херам:<br><br><fieldset><legend>sql</legend><code><br />
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> og<span style="color: #66cc66;">.</span>goods_sn num_iid<span style="color: #66cc66;">,</span> SUM<span style="color: #66cc66;">&#40;</span>og<span style="color: #66cc66;">.</span>goods_number<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> goods_number <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`ecs_taobaosruruorder_info`</span> <span style="color: #993333; font-weight: bold;">AS</span> o<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`ecs_taobaosruruorder_goods`</span> <span style="color: #993333; font-weight: bold;">AS</span> og <span style="color: #993333; font-weight: bold;">WHERE</span> 1 &nbsp;<span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> og<span style="color: #66cc66;">.</span>goods_sn <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> goods_number <span style="color: #993333; font-weight: bold;">DESC</span>;<br />
&nbsp;</code></fieldset><br><br>Запрос возвращает чуть больше 5к строк и иногда выполняется по 14 секунд, иногда по 30.<br><br><fieldset><legend>sql</legend><code><br />
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">DESC</span> ecs_taobaosruruorder_goods;<br />
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------------+-----------------------+------+-----+---------+----------------+</span><br />
<span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">FIELD</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #66cc66;">|</span> Extra &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------------+-----------------------+------+-----+---------+----------------+</span><br />
<span style="color: #66cc66;">|</span> rec_id &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> mediumint<span style="color: #66cc66;">&#40;</span>8<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> PRI <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> &nbsp; &nbsp;<span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span> <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> order_id &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> mediumint<span style="color: #66cc66;">&#40;</span>8<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> 0 &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> goods_id &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> bigint<span style="color: #66cc66;">&#40;</span>20<span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> YES &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> goods_name &nbsp; &nbsp; <span style="color: #66cc66;">|</span> varchar<span style="color: #66cc66;">&#40;</span>120<span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> goods_sn &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> varchar<span style="color: #66cc66;">&#40;</span>60<span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> MUL <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> product_id &nbsp; &nbsp; <span style="color: #66cc66;">|</span> mediumint<span style="color: #66cc66;">&#40;</span>8<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> 0 &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> goods_number &nbsp; <span style="color: #66cc66;">|</span> smallint<span style="color: #66cc66;">&#40;</span>5<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> &nbsp;<span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> MUL <span style="color: #66cc66;">|</span> 1 &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> market_price &nbsp; <span style="color: #66cc66;">|</span> decimal<span style="color: #66cc66;">&#40;</span>10<span style="color: #66cc66;">,</span>2<span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> 0<span style="color: #66cc66;">.</span>00 &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> goods_price &nbsp; &nbsp;<span style="color: #66cc66;">|</span> decimal<span style="color: #66cc66;">&#40;</span>10<span style="color: #66cc66;">,</span>2<span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> 0<span style="color: #66cc66;">.</span>00 &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> goods_attr &nbsp; &nbsp; <span style="color: #66cc66;">|</span> text &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> send_number &nbsp; &nbsp;<span style="color: #66cc66;">|</span> smallint<span style="color: #66cc66;">&#40;</span>5<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> &nbsp;<span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> 0 &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> is_real &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> tinyint<span style="color: #66cc66;">&#40;</span>1<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> &nbsp; <span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> 0 &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> extension_code <span style="color: #66cc66;">|</span> varchar<span style="color: #66cc66;">&#40;</span>30<span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> parent_id &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> mediumint<span style="color: #66cc66;">&#40;</span>8<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> 0 &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> is_gift &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> smallint<span style="color: #66cc66;">&#40;</span>5<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> &nbsp;<span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> 0 &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> goods_attr_id &nbsp;<span style="color: #66cc66;">|</span> varchar<span style="color: #66cc66;">&#40;</span>255<span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> NO &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> comment &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> text &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> YES &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> trackcode &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> varchar<span style="color: #66cc66;">&#40;</span>50<span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> YES &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> goods_status &nbsp; <span style="color: #66cc66;">|</span> varchar<span style="color: #66cc66;">&#40;</span>50<span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> YES &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> goods_attr_val <span style="color: #66cc66;">|</span> varchar<span style="color: #66cc66;">&#40;</span>255<span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> YES &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> goods_thumb &nbsp; &nbsp;<span style="color: #66cc66;">|</span> varchar<span style="color: #66cc66;">&#40;</span>255<span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> YES &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------------+-----------------------+------+-----+---------+----------------+</span><br />
21 rows <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.00</span> sec<span style="color: #66cc66;">&#41;</span><br />
&nbsp;</code></fieldset><br><br> Смотрим, как по учебнику<br><br><fieldset><legend>sql</legend><code><br />
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">EXPLAIN</span> EXTENDED <span style="color: #993333; font-weight: bold;">SELECT</span> og<span style="color: #66cc66;">.</span>goods_sn num_iid<span style="color: #66cc66;">,</span> SUM<span style="color: #66cc66;">&#40;</span>og<span style="color: #66cc66;">.</span>goods_number<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> goods_number <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`ecs_taobaosruruorder_info`</span> <span style="color: #993333; font-weight: bold;">AS</span> o<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`ecs_taobaosruruorder_goods`</span> <span style="color: #993333; font-weight: bold;">AS</span> og <span style="color: #993333; font-weight: bold;">WHERE</span> 1 &nbsp;<span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> og<span style="color: #66cc66;">.</span>goods_sn <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> goods_number <span style="color: #993333; font-weight: bold;">DESC</span>;<br />
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----+-------------+-------+-------+---------------+--------------+---------+------+------+----------+----------------------------------------------+</span><br />
<span style="color: #66cc66;">|</span> id <span style="color: #66cc66;">|</span> select_type <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #66cc66;">|</span> type &nbsp;<span style="color: #66cc66;">|</span> possible_keys <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">KEY</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> key_len <span style="color: #66cc66;">|</span> ref &nbsp;<span style="color: #66cc66;">|</span> rows <span style="color: #66cc66;">|</span> filtered <span style="color: #66cc66;">|</span> Extra &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----+-------------+-------+-------+---------------+--------------+---------+------+------+----------+----------------------------------------------+</span><br />
<span style="color: #66cc66;">|</span> &nbsp;1 <span style="color: #66cc66;">|</span> SIMPLE &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> o &nbsp; &nbsp; <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">INDEX</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> order_status <span style="color: #66cc66;">|</span> 1 &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">|</span> 1421 <span style="color: #66cc66;">|</span> &nbsp; 100<span style="color: #66cc66;">.</span>00 <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">USING</span> <span style="color: #993333; font-weight: bold;">INDEX</span>; <span style="color: #993333; font-weight: bold;">USING</span> <span style="color: #993333; font-weight: bold;">TEMPORARY</span>; <span style="color: #993333; font-weight: bold;">USING</span> filesort <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> &nbsp;1 <span style="color: #66cc66;">|</span> SIMPLE &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> og &nbsp; &nbsp;<span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">ALL</span> &nbsp; <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> &nbsp; &nbsp;<span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">|</span> 8030 <span style="color: #66cc66;">|</span> &nbsp; 100<span style="color: #66cc66;">.</span>00 <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">USING</span> <span style="color: #993333; font-weight: bold;">JOIN</span> buffer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----+-------------+-------+-------+---------------+--------------+---------+------+------+----------+----------------------------------------------+</span><br />
2 rows <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span> warning <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.00</span> sec<span style="color: #66cc66;">&#41;</span><br />
&nbsp;</code></fieldset><br><br>Так и не понял, какого хрена не используется ни один индекс для талбицы ecs_taobaosruruorder_goods. но если мне память не изменяет, то SUM() как бы должен ответить на этот вопрос кэпом.<br><br>ОК, идем дальше:<br><br><fieldset><legend>sql</legend><code><br />
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SET</span> profiling<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>;<br />
Query OK<span style="color: #66cc66;">,</span> 0 rows affected <span style="color: #66cc66;">&#40;</span>0<span style="color: #66cc66;">.</span>00 sec<span style="color: #66cc66;">&#41;</span><br />
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> SQL_NO_CACHE og<span style="color: #66cc66;">.</span>goods_sn num_iid<span style="color: #66cc66;">,</span> SUM<span style="color: #66cc66;">&#40;</span>og<span style="color: #66cc66;">.</span>goods_number<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> goods_number <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`ecs_taobaosruruorder_info`</span> <span style="color: #993333; font-weight: bold;">AS</span> o<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`ecs_taobaosruruorder_goods`</span> <span style="color: #993333; font-weight: bold;">AS</span> og <span style="color: #993333; font-weight: bold;">WHERE</span> 1 &nbsp;<span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> og<span style="color: #66cc66;">.</span>goods_sn <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> goods_number <span style="color: #993333; font-weight: bold;">DESC</span>;<br />
<br />
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------------+--------------+</span><br />
<span style="color: #66cc66;">|</span> num_iid &nbsp; &nbsp; <span style="color: #66cc66;">|</span> goods_number <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------------+--------------+</span><br />
<span style="color: #66cc66;">|</span> 9566256455 &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; 154889 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> 9300994544 &nbsp;<span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp;80997 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> 14471064410 <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp;71050 <span style="color: #66cc66;">|</span><br />
<br />
<span style="color: #66cc66;">......</span><br />
<br />
<span style="color: #66cc66;">|</span> 15555915336 <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> 14973389548 <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> 12264019380 <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> 16190905553 <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> 14334037357 <span style="color: #66cc66;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------------+--------------+</span><br />
5039 rows <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span>14<span style="color: #66cc66;">.</span>13 sec<span style="color: #66cc66;">&#41;</span><br />
<br />
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SHOW</span> profile <span style="color: #993333; font-weight: bold;">FOR</span> query <span style="color: #cc66cc;">5</span>;<br />
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------------------+-----------+</span><br />
<span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">STATUS</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> Duration &nbsp;<span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------------------+-----------+</span><br />
<span style="color: #66cc66;">|</span> starting &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000063 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> checking permissions <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000005 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> checking permissions <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000005 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> Opening <span style="color: #993333; font-weight: bold;">TABLES</span> &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000020 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> System <span style="color: #993333; font-weight: bold;">LOCK</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000010 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> init &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000017 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> optimizing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000006 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> statistics &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000010 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> preparing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000022 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> Creating tmp <span style="color: #993333; font-weight: bold;">TABLE</span> &nbsp; <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000030 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> executing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000004 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> Copying <span style="color: #993333; font-weight: bold;">TO</span> tmp <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #66cc66;">|</span> 14<span style="color: #66cc66;">.</span>129446 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> Sorting result &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>001820 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> Sending <span style="color: #993333; font-weight: bold;">DATA</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>001436 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> end &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000005 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> removing tmp <span style="color: #993333; font-weight: bold;">TABLE</span> &nbsp; <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000115 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> end &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000005 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> query end &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000003 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> closing <span style="color: #993333; font-weight: bold;">TABLES</span> &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000007 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> freeing items &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000010 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> logging slow query &nbsp; <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000003 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> logging slow query &nbsp; <span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000040 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">|</span> cleaning up &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">|</span> &nbsp;0<span style="color: #66cc66;">.</span>000004 <span style="color: #66cc66;">|</span><br />
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------------------+-----------+</span><br />
23 rows <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.00</span> sec<span style="color: #66cc66;">&#41;</span><br />
&nbsp;</code></fieldset><br><br>да, кеш я отключил специально. Но что за нафиг и пчему так долго копичет в tmp_table? Особенно учитывая тот факт, что tmpdir уже хз сколько успешно сидит на tmpfs и ниразу не вылазит на диск - места ему хватает.</p>]]></description>
</item>
</channel>
</rss>