Naoya Murakami
visio****@gmail*****
2013年 8月 27日 (火) 00:20:34 JST
お世話になっております。村上と申します。
mroongaの一利用者ですが、mroongaのパフォーマンスに興味があったので、
別作業の解凍待ち時間の間に、データをダウンロードして、性能を少し試してみました。
ご参考まで。
・環境
CentOS6.4
mysql5.6.13
mroonga-3.06.2013.08.26
groonga-3.0.6.2013.08.26
・サーバスペック
Xeon E5-2407 2.20GHz 4core
メモリ32GB
SSD 240x4 のRAID0
<INNODBラッパーモード>
mysql> select count(guid) from CombinedData where match(content)
against('事件' IN BOOLEAN MODE);
+-------------+
| count(guid) |
+-------------+
| 89072 |
+-------------+
1 row in set (0.03 sec)
※mysql5.6系の場合、mroongaのcount最適化ではないmysql由来の方法?でcountが最適化されている。なお、5.5系では、最適化されない。myisamのラッパーだと、3.06で追加されたmroongaのcount最適化が走る。
mysql> select count(guid) from CombinedData where match(content)
against('事件' IN BOOLEAN MODE) and orgId='ee15e1b414ad4329b7d14c857bc91644'
and objId='e9823fae423b4b56859ba98cb8a3a8dc';
+-------------+
| count(guid) |
+-------------+
| 172 |
+-------------+
1 row in set (3.88 sec)
mysql5.6系のcount最適化がきかない。林さんの結果と同じ。ハードにボトルネックがないため、
ハードスペックをいくらあげても、同じデータ構造、同じSQLであれば、これ以上は早くならなそう。
レコードアクセスを含む全件カウントはコストが高そう。
mysql> select guid from CombinedData where match(content) against('事件' IN
BOOLEAN MODE) and orgId='ee15e1b414ad
4329b7d14c857bc91644' and objId='e9823fae423b4b56859ba98cb8a3a8dc' limit 1;
+----------------------------------+
| guid |
+----------------------------------+
| 00e11568de5e432fbfe16a56bd650d70 |
+----------------------------------+
1 row in set (0.03 sec)
リミットで一部のデータ取得であれば、早くかえってくる。
<mroongaストレージモード>
innodbラッパー→mroongaストレージモードに変換
mysql> select count(guid) from CombinedData where match(content)
against('事件' IN BOOLEAN MODE);
+-------------+
| count(guid) |
+-------------+
| 89072 |
+-------------+
1 row in set (0.11 sec)
mysql由来のカウント最適化よりやや劣る?
mysql> select count(guid) from CombinedData where match(content)
against('事件' IN BOOLEAN MODE) and orgId='ee15e1b414ad4329b7d14c857bc91644'
and objId='e9823fae423b4b56859ba98cb8a3a8dc';
+-------------+
| count(guid) |
+-------------+
| 172 |
+-------------+
1 row in set (0.52 sec)
最適化きいてないのにラッパーよりかなりはやいなぁ。。
mysql> SHOW STATUS LIKE 'Mroonga_count_skip';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| Mroonga_count_skip | 0 |
+--------------------+-------+
1 row in set (0.00 sec)
ysql> select count(guid) from CombinedData where match(content) against('事件
+ orgId:ee15e1b414ad4329b7d14c857bc91644 +
objId:e9823fae423b4b56859ba98cb8a3a8dc' IN BOOLEAN MODE) ;
+-------------+
| count(guid) |
+-------------+
| 172 |
+-------------+
1 row in set (0.07 sec)
againstの中に、groongaのクエリ構文を指定する方法だとさらに早い。
この書き方、裏技チックで面白い。かなり性能を向上できるのですばらしい。
mysql> SHOW STATUS LIKE 'Mroonga_count_skip';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| Mroonga_count_skip | 0 |
+--------------------+-------+
1 row in set (0.00 sec)
この書き方でもカウントスキップはインクリメントされないのですね。
count最適化が走っているわけではないのかなぁ。
以上です。