Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put a draft of a blog article that introduces grn_ts
- Loading branch information
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| --- | ||
| layout: post.ja | ||
| title: grn_ts (ぐるんたす)の紹介 | ||
| description: grn_ts を紹介します! | ||
| published: false | ||
| --- | ||
|
|
||
| ## grn_ts (ぐるんたす)の紹介 | ||
|
|
||
| Groonga の実験的な機能として, `select` の新しい内部エンジン grn_ts が追加されています. grn_ts の TS は Turbo Selector の略であり,まだ使えない機能がたくさんあるものの,単純なフィルタリングをおこなうだけであれば,従来エンジンより高速に動作します.以下, grn_ts の特徴や使い方を簡単に紹介します. | ||
|
|
||
| ### 特徴 | ||
|
|
||
| grn_ts は Groonga が列指向なデータベースであることを強く意識した実装となっているため,特にカラムの走査が高速です. 擬似乱数を保存した 10 列 x 100 万行のテーブルを使った実験では,索引を使わない検索速度が従来エンジンと比べて **約 10 倍** になることが確認されています. | ||
|
|
||
| 高速な検索以外の特徴として, `output_columns` に式を記述することができます.たとえば, `--output_columns '_id, _key, ColA + ColB'` と記述すれば, `_id`, `_key` に加えて `ColA + ColB` を評価した結果が出力されます. | ||
|
|
||
| ### 有効にする方法 | ||
|
|
||
| grn_ts はまだ実験的な機能であり,デフォルトでは有効になっていません. grn_ts を有効化するには, `configure` スクリプトを実行するとき,以下のように指定してください. `GRN_WITH_TS` というマクロが定義され, grn_ts が有効になります. | ||
|
|
||
| ``` | ||
| $ ./configure CFLAGS="-g -O2 -DGRN_WITH_TS" | ||
| ``` | ||
|
|
||
| 現在は Ubuntu 14.04 で開発を進めているため,ほかの環境ではビルドに失敗したり,動作がおかしくなったりする可能性があります.問題が見つかったときは, [GitHub Issues](https://github.com/groonga/groonga/issues) や [メーリングリスト](http://lists.osdn.me/mailman/listinfo/groonga-dev) よりご連絡ください. | ||
|
|
||
| ### 使い方 | ||
|
|
||
| `select` の `filter` を指定するとき,先頭に `?` を追加すれば grn_ts が適用されます.以下に例を示します.以下の例において, `Table` は擬似乱数を保存した 10 列 x 100 万行のテーブルです.従来エンジンと grn_ts の検索時間を比較すると, grn_ts では約 1/10 に短縮されていることがわかります. | ||
|
|
||
| ``` | ||
| > # 従来エンジン | ||
| > select Table --filter 'Col0 < 50' --output_columns '_id, Col0' | ||
| [[0,1444290905.65602,0.2112135887146], | ||
| [[[499510], | ||
| [["_id","UInt32"],["Col0","Int64"]], | ||
| [4,41],[5,13],[9,23],[11,25],[13,26],[15,24],[16,40],[19,30],[21,29],[24,20]]]] | ||
| > # grn_ts | ||
| > select Table --filter '?Col0 < 50' --output_columns '_id, Col0' | ||
| [[0,1444290923.81565,0.0201132297515869], | ||
| [[[499510], | ||
| [["_id","UInt32"],["Col0","Int64"]], | ||
| [4,41],[5,13],[9,23],[11,25],[13,26],[15,24],[16,40],[19,30],[21,29],[24,20]]]] | ||
| ``` | ||
|
|
||
| 次に `output_columns` に式を記述した `select` の例を示します.従来であればカラム名が出力されるところには,式がそのまま出力されています. | ||
|
|
||
| ``` | ||
| > select Table --filter '?Col0 + Col1 < 100 ' --output_columns '_id, Col0, Col1, Col0 + Col1' | ||
| [[0,1444291081.77697,0.0250604152679443], | ||
| [[[505001], | ||
| [["_id","UInt32"],["Col0","Int64"],["Col1","Int64"],["Col0 + Col1","Int64"]], | ||
| [4,41,8,49],[6,57,21,78],[7,51,10,61],[9,23,53,76],[11,25,51,76], | ||
| [13,26,2,28],[15,24,47,71],[16,40,51,91],[17,67,31,98],[18,66,10,76]]]] | ||
| ``` | ||
|
|
||
| ※ 見やすくするため,検索結果には改行を挿入しています. | ||
|
|
||
| ### 制限事項 | ||
|
|
||
| 現在, grn_ts で使える `select` のオプションは以下の通りです. | ||
|
|
||
| - `filter` | ||
| - `output_columns` | ||
| - `offset` | ||
| - `limit` | ||
|
|
||
| ただし,関数や索引が使えなかったり,テーブル参照が暗黙的に解決されなかったり,一部の演算子に対応していなかったりという制限があります.具体的な制限については,日々更新されていくため,ここでは省略させていただきます. | ||
|
|
||
| ### 今後 | ||
|
|
||
| 今後の課題として大きなものを挙げると以下のようになります. | ||
|
|
||
| - 整列 | ||
| - 索引 | ||
| - 全文検索 | ||
| - ドリルダウン | ||
|
|
||
| 近い内に,どの機能から実装を進めて欲しいかを尋ねるアンケートをさせていただくかもしれません. |