<!DOCTYPE html>
<html>
<head>
</head>
<body>
<dl style="line-height: 1.5; margin-left: 2em">
<dt style="clear: both; float: left; font-weight: bold; width: 8em">Author</dt>
<dd style="margin-left: 8.5em">Tetsuro IKEDA <ikdtt****@gmail*****></dd>
<dt style="clear: both; float: left; font-weight: bold; width: 8em">Date</dt>
<dd style="margin-left: 8.5em">2010-10-26 15:05:06 +0900 (Tue, 26 Oct 2010)</dd>
<dt style="clear: both; float: left; font-weight: bold; width: 8em">New Revision</dt>
<dd style="margin-left: 8.5em"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988">f416d158971096389b8bc9cb596676fef5f7e988</a></dd>
<dt style="clear: both; float: left; font-weight: bold; width: 8em">Log</dt>
<dd style="margin-left: 8.5em"><pre style="border: 1px solid #aaa; font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace; line-height: 1.2; padding: 0.5em">added decription of "count skip" to userguide document.</pre></dd>
<dt style="clear: both; float: left; font-weight: bold; width: 8em">Modified files</dt>
<dd style="margin-left: 8.5em">
<ul>
<li><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#diff-0">doc/ja/source/userguide.rst</a></li>
</ul>
</dd>
</dl>
<div class="diff-section" style="clear: both">
<table style="border-collapse: collapse; border: 1px solid #aaa">
<thead>
<tr class="diff-header" style="border: 1px solid #aaa">
<td colspan="3">
<pre style="border: 0; font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace; line-height: 1.2; margin: 0; padding: 0.5em; white-space: normal"><span class="diff-header" style="background-color: #eaf2f5; color: #999999; display: block; white-space: pre"> Modified: doc/ja/source/userguide.rst (+25 -1)</span>
<span class="diff-header-mark" style="background-color: #eaf2f5; color: #999999; display: block; white-space: pre">===================================================================</span>
</pre>
</td>
</tr>
</thead>
<tbody>
<tr>
<th class="diff-line-number" style="border: 1px solid #aaa">
<pre style="border: 0; font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace; line-height: 1.2; margin: 0; padding: 0.5em; white-space: normal"><span class="diff-line-number-hunk-header" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0L106">...</a></span>
<span class="diff-line-number-not-changed" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0L107">107</a></span>
<span class="diff-line-number-not-changed" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0L108">108</a></span>
<span class="diff-line-number-not-changed" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0L109">109</a></span>
<span class="diff-line-number-deleted" style="background-color: #ffaaaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0L110">110</a></span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-not-changed" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0L111">111</a></span>
<span class="diff-line-number-not-changed" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0L112">112</a></span>
<span class="diff-line-number-not-changed" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0L113">113</a></span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
</pre>
</th>
<th class="diff-line-number" style="border: 1px solid #aaa">
<pre style="border: 0; font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace; line-height: 1.2; margin: 0; padding: 0.5em; white-space: normal"><span class="diff-line-number-hunk-header" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R106">...</a></span>
<span class="diff-line-number-not-changed" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R107">107</a></span>
<span class="diff-line-number-not-changed" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R108">108</a></span>
<span class="diff-line-number-not-changed" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R109">109</a></span>
<span class="diff-line-number-nothing" style="display: block; white-space: pre"> </span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R110">110</a></span>
<span class="diff-line-number-not-changed" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R111">111</a></span>
<span class="diff-line-number-not-changed" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R112">112</a></span>
<span class="diff-line-number-not-changed" style="display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R113">113</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R114">114</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R115">115</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R116">116</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R117">117</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R118">118</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R119">119</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R120">120</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R121">121</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R122">122</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R123">123</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R124">124</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R125">125</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R126">126</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R127">127</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R128">128</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R129">129</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R130">130</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R131">131</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R132">132</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R133">133</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R134">134</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R135">135</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R136">136</a></span>
<span class="diff-line-number-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre"><a href="https://github.com/mroonga/mroonga/commit/f416d158971096389b8bc9cb596676fef5f7e988#L0R137">137</a></span>
</pre>
</th>
<td class="diff-content" style="border: 1px solid #aaa">
<pre style="border: 0; font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace; line-height: 1.2; margin: 0; padding: 0.5em; white-space: normal"><span class="diff-hunk-header" style="background-color: #eaf2f5; color: #999999; display: block; white-space: pre">@@ -107,7 +107,31 @@ <span class="diff-context" style="background-color: #ffffaa; color: #000000">groongaでは各カラムごとにファイルを分けてデータを格納す</span></span>
<span class="diff-not-changed" style="display: block; white-space: pre"> </span>
<span class="diff-not-changed" style="display: block; white-space: pre"> SELECT c1, c2, c11 FROM t1 WHERE c2 = XX AND c12 = "XXX";</span>
<span class="diff-not-changed" style="display: block; white-space: pre"> </span>
<span class="diff-deleted" style="background-color: #ffaaaa; color: #000000; display: block; white-space: pre">-このケースではc1,c2,c11,c12に対してのみアクセスが行われることになります。</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+このケースではc1,c2,c11,c12に対してのみアクセスが行われ、SQL文が高速に処理されることになります。</span>
<span class="diff-not-changed" style="display: block; white-space: pre"> </span>
<span class="diff-not-changed" style="display: block; white-space: pre"> 行カウント高速化</span>
<span class="diff-not-changed" style="display: block; white-space: pre"> ----------------------------</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+COUNT(*)などの行カウントを行う場合と通常のSELECTによるデータ参照を行う場合に対して、従来よりMySQLではストレージエンジンの呼び出しを行う部分(=ストレージエンジンインタフェース)における区別が存在していないため、行数をカウントするだけで良いような場合にもレコードアクセス(SELECTの結果には含まれないデータへのアクセス)が行われる問題があります。</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+groongaストレージエンジンの前身であるTritonn(MySQL+Senna)ではこの問題に対して"2indパッチ"という不要なレコードアクセスを省略する仕組みを独自に実装してこの性能問題を回避していました。</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+これに引き続き、groongaストレージエンジンでも行カウントを高速化するための仕組みを実装しています。</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+例えば以下のSELECT文では不要なカラムデータの読み取りは省略され、必要最小限のコストで行カウントの結果を返すことができます。 ::</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+ SELECT COUNT(*) FROM t1 WHERE MATCH(c2) AGAINST("hoge");</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+行カウント高速化の処理が行われたかどうかはステータス変数で確認することもできます。::</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+ mysql> show status like 'groonga_count_skip';</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+ +--------------------+-------+</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+ | Variable_name | Value |</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+ +--------------------+-------+</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+ | groonga_count_skip | 1 |</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+ +--------------------+-------+</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+ 1 row in set (0.00 sec)</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+行カウント高速化の処理が行われる度に ``groonga_count_skip`` ステータス変数がインクリメントされます。</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+</span>
<span class="diff-added" style="background-color: #aaffaa; color: #000000; display: block; white-space: pre">+備考:この高速化機能はインデックスを用いて実装されています。テーブルスキャンが行われるパタンでは高速化は行われません。</span>
</pre>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>