SlideShare a Scribd company logo
1 of 83
Download to read offline
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
PGroongaMake PostgreSQL
fast full text search platform
for all languages!
Kouhei Sutou ClearCode Inc.
PGConf.ASIA 2016
2016-12-03
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
PostgreSQL and me
PostgreSQLと私
Some my
patches are
mergedいくつかパッチがマージされている
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Patches
パッチ
#13840: pg_dump generates
unloadable SQL
pg_dumpがリストアできないSQLを出力する
#14160: DROP ACCESS METHOD
IF EXISTS isn't impl.
DROP ACCESS METHOD IF EXISTSが実装されていない
They are found while
developing PGroonga
どちらもPGroonga開発中に見つけた問題
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
PGroonga dev style
PGroongaの開発スタイル
When there are problems in
related projects including
PostgreSQL
PostgreSQLを含む関連プロジェクトに問題があった場合
We fix these problems in these
projects instead of choosing
workaround in PGroonga
PGroonga側で回避するのではなく
関連プロジェクトの方で問題を直す
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
PostgreSQL and FTS
PostgreSQLと全文検索
PostgreSQL has built-in
full text search feature
PostgreSQLには組込の全文検索機能がある
It has some problems...
ただ、いくつか問題がある
We fixed them by PGroonga
PGroongaを開発することでそれらの問題を修正した
instead of fixing PostgreSQL 😓
PostgreSQLを修正するのではなくて…
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Because...
理由は…
Our approach is different
from PostgreSQL's approach
PGroongaのやり方はPostgreSQLのやり方と違う
1.
PG provides plugin system
PostgreSQLはプラグインの仕組みを提供している
Implementing as a plugin is
PostgreSQL way!
プラグインでの実装はPostgreSQLらしいやり方!
2.
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
PG FTS problem
PostgreSQLの全文検索の問題
Many langs aren't supported
サポートしていない言語がたくさんある
e.g.: Asian languages
例:アジアの言語
Japanese, Chinese and more
日本語や中国語など
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
FTS for Japanese1
日本語の全文検索1
SELECT
to_tsvector('japanese',
'こんにちは');
-- ERROR: text search configuration
-- "japanese" does not exist
-- LINE 2: to_tsvector('japanese',
-- ^
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
FTS for Japanese2
日本語の全文検索2
CREATE EXTENSION pg_trgm;
SELECT show_trgm('こんにちは');
-- show_trgm
-- -----------
-- {} ← Must not empty!
-- (1 row)
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Existing solution
既存の解決策
pg_bigm
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
pg_bigm
An extension
拡張機能
Similar to pg_trgm
pg_trgmと似ている
Operator class for GIN
GIN用の演算子クラス
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
pg_bigm: Usage
pg_bigm:使い方
CREATE INDEX index ON table
USING GIN (column gin_bigm_ops);
-- ↑Use GIN ↑Specify op class
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
pg_bigm: Demerit
pg_bigm:デメリット
Slow for large document
文書が長いと遅い
(Normally, we want to use FTS for large document)
(普通は長い文書に対して全文検索したい)
Because it needs "recheck"
「recheck」が必要だから
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
"recheck"
"Exact" seq. search after
"loose" index search
「ゆるい」インデックス検索の後に実行する
「正確な」シーケンシャルサーチ
The larger text, the slower
対象テキストが大きければ大きいほど遅くなる
text = doc size * N docs
対象テキスト = 文書サイズ * 文書数
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Benchmark
ベンチマーク
0
0.5
1
1.5
2
2.5
3
311 14706 20389
Data: Japanese Wikipedia
(Many records and large documents)
N records: About 0.9millions
Average text size: 6.7KiB
Slow
Slow
Elapsedtime(sec)
(Lowerisbetter)
N hits
pg_bigm
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
New solution
新しい解決策
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
PGroonga
Pronunciation: píːzí:lúnɡά
読み方:ぴーじーるんが
An extension
拡張機能
Index and operator classes
インデックスと演算子クラス
Not operator classes for GIN
GINの演算子クラスではない
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
PGroonga layer
GIN
textsearch
pg_trgm
pg_bigm
Index
Operator
class
PGroonga
PGroonga
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Benchmark
ベンチマーク
0
0.5
1
1.5
2
2.5
3
311 14706 20389
Data: Japanese Wikipedia
(Many records and large documents)
N records: About 0.9millions
Average text size: 6.7KiB
Fast Fast
Elapsedtime(sec)
(Lowerisbetter)
N hits
PGroonga pg_bigm
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Wrap up1
まとめ1
PostgreSQL doesn't support
Asian languages
PostgreSQLはアジアの言語をサポートしていない
pg_bigm and PGroonga
support all languages
pg_bigmとPGroongaはすべての言語をサポートしている
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Wrap up2
まとめ2
Many hits case:
ヒット数が多い場合
pg_bigm is slow
pg_bigmは遅い
PGroonga is fast
PGroongaは速い
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Why is PGroonga fast?
PGroongaはどうして速いのか
Doesn't need "recheck"
「recheck」が必要ないから
Is "recheck" really slow?
本当に「recheck」が遅いの?
See one more benchmark result
もう一つベンチマーク結果を見てみましょう
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Benchmark
ベンチマーク
0
0.5
1
1.5
2
2.5
3
0 100000 200000 300000 400000 500000
Data: Japanese Wikipedia
(Many records and large documents)
N records: About 0.9millions
Average text size: 6.7KiB
Slow
Slow
Fast for many hits!
Query: "日本"
Elapsedtime(sec)
(Lowerisbetter)
N hits
PGroonga pg_bigm
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Why is pg_bigm fast?
pg_bigmはどうして速いのか
Query is "日本"
クエリーは「日本」
Point: 2 characters
ポイント:2文字
pg_bigm doesn't need
"recheck" for 2 chars query
pg_bigmは2文字のクエリーに「recheck」の必要がない
It means that "recheck" is slow
つまり「recheck」が遅いということ
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
N-gram and "recheck"
N-gramと「recheck」
N-gram approach needs
"phrase search" when query
has N+1 or more characters
N+1文字以上のクエリーには「フレーズ検索」が必要
N=2 for pg_bigm, N=3 for pg_trgm
pg_bigmはN=2でpg_trgmはN=3
GIN needs "recheck" for
"phrase search"
GINは「フレーズ検索」には「recheck」が必要
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Phrase search
フレーズ検索
Phrase search is "token
search" and "position check"
フレーズ検索は「トークン検索」と「位置チェック」
Tokens must exist and be ordered
トークンは同じ順序で出現していないといけない
OK: "car at" for "car at" query
NG: "at car" for "car at" query
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
N-gram and phrase search
Split text to tokens
テキストをトークンに分割
"cat"→"ca","at"
1.
Search all tokens
すべてのトークンを検索
"ca" & "at" exist: Candidate!
2.
Check appearance pos.
出現位置をチェック
"ca" then "at": Found!
3.
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
N-gram and GIN: Create
N-gramとGIN:作成
GIN
"ca","at"
Tokenize
Documents
cat
at car
10
20
ID Text
"ca"
"at"
"t "
Token Posting list
10,20
10,20
20
" c"
"ar"
20
20
"at","t "," c","ca","ar"
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
N-gram and GIN: Search
N-gramとGIN:検索
"ca"
"at"
"t "
Token Posting list
GIN
10,20
10,20
20
cat Query
"ca","at"
Tokenize
AND
cat
at car
10
20
Documents
ID Text
10,20
Candidates" c"
"ar"
20
20
Search
Appearance position check
(Point: Out of GIN)
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
GIN and phrase search
GINとフレーズ検索
Phrase search needs
position check
フレーズ検索では出現位置チェックが必要
GIN doesn't support
position check
GINは出現位置チェックをサポートしていない
→GIN needs "recheck"→Slow!
GINでは「recheck」が必要だから遅い
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Why is PGroonga fast?
PGroongaはどうして速いのか
PGroonga uses N-gram by default
PGroongaはデフォルトでN-gramを使っている
But doesn't need "recheck"
PGroongaは「recheck」の必要がない
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Why no "recheck"?
どうして「recheck」が必要ないのか
PGroonga uses
full
inverted indexPGroongaは完全転置インデックスを使っているから
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Full inverted index
完全転置インデックス
Including
position位置情報を含む
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Inverted index diff
転置インデックスの違い
cat
at car
10
20
Documents
Full: Doc ID + pos
"ca"
"at"
"t "
ID Text
Token Posting list
20:2
10:2,20:1
10:1,20:4
"ca","at"
1 2
"at","t "," c","ca","ar"
1 2 3 4 5
Tokenize
Not full: Only doc ID
" c"
"ar"
20:3
20:5
"ca"
"at"
"t "
Token Posting list
20
10,20
10,20
" c"
"ar"
20
20
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
N-gram/PGroonga: Search
N-gramとPGroonga:検索
"ca"
"at"
"t "
Token Posting list
PGroonga
10:1,20:4
10:2,20:1
20:2
cat Query
Tokenize
AND
cat
at car
10
20
Documents
ID Text
10
Result
" c"
"ar"
20:3
20:5
Search
Appearance position check
(Point: In PGroonga)
"ca","at"
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Wrap up
まとめ
N-gram needs phrase search
N-gramの場合はフレーズ検索が必要
Full inverted index
provides fast phrase search
完全転置インデックスを使うと高速にフレーズ検索でき
る
GIN isn't full inverted index
GINは完全転置インデックスではない
PGroonga uses full inverted
index
PGroongaは完全転置インデックスを使っている
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
FTS and English(*)
全文検索と英語
Normally, N-gram isn't used
for English FTS
普通は英語の全文検索にN-gramを使わない
N-gram is slower than word
based approach (textsearch
approach)
N-gramは単語ベースのやり方(textsearchのやり方)
より遅め
Stemming/stop word can't be used
N-gramではステミングとストップワードを使えない
(*) English≒Alphabet based languages
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
PGroonga and English
PGroongaと英語
PGroonga uses N-gram by default
PGroongaはデフォルトではN-gramを使う
Is PGroonga slow for English?
ではPGroongaは英語では遅いのか?
No. Similar to textsearch
遅くない。textsearchと同じくらい
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
PGroonga: Search
PGroonga:検索
0
0.2
0.4
0.6
0.8
1
1.2
1.4
PostgreSQL OR MySQL database America
Data: English Wikipedia
(Many records and large docs)
N records: About 5.3millions
Average text size: 6.4KiB
Elapsedtime(ms)
(Shorterisbetter)
Query
PGroonga textsearch
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
PGroonga's N-gram
Variable size N-gram
可変長サイズのN-gram
Continuous alphabets are 1 token
(= word based approach)
連続したアルファベットは1トークン(=単語ベース)
Hello→"Hello" not "He","el",…
No alphabet is 2-gram
非アルファベットは2-gram
こんにちは→"こん","んに",…
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Wrap up1
まとめ1
PGroonga's search is fast
for all languages
PGroongaの検索はすべての言語で速い
Including alphabet based
languages and Asian languages
mixed case
アルファベットベースの言語とアジアの言語が混ざっ
た場合でも速い
(textsearch doesn't support mixed case)
(textsearchは言語を混ぜることはできない)
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Wrap up2
まとめ2
PGroonga makes PostgreSQL
fast full text search platform
for all languages!
PGroongaでPostgreSQLが
全言語対応高速全文検索プラットフォームになる!
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
More about PGroonga
PGroongaについてもっと
Performance
性能
Japanese specific feature
日本語向けの機能
JSON support
JSONサポート
Replication
レプリケーション
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Performance
性能
Search and update
検索と更新
Index only scan
インデックスオンリースキャン
Direct Groonga search
直接Groongaで検索
Index creation
インデックス作成
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Search and update
検索と更新
Doesn't decrease search
performance while updating
更新中も検索性能が落ちない
It's good characteristics for
chat application
チャットアプリでうれしい傾向
Zulip supports PGroonga
Zulip: OSS chat app by Dropbox
ZulipはPGroongaをサポートしている
ZulipはDropboxが開発しているOSSのチャットアプリ
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Characteristics
傾向
Searchthroughput
Update throughput
PGroonga
Searchthroughput
Update throughput
GIN
Keep
search performance
while many updates
Decrease
search performance
while updating
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Update and lock
更新とロック
Update without read locks
参照ロックなしで更新
Write locks are required
書き込みロックは必要
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
GIN: Read/Write
GIN:読み書き
Conn1
Conn2
INSERT
start
SELECT
start
Blocked
INSERT
finish
SELECT
finish
GIN
Slow down!
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
PGroonga: Read/Write
PGroonga:読み書き
Conn1
Conn2
INSERT
start
SELECT
start
INSERT
finish
SELECT
finish
PGroonga
No slow down!
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Fast stably
安定して速い
GIN has intermittent
performance decrements
GINは間欠的な性能劣化がある
For details:🔎"GIN pending list"
詳細は「GIN pending list」で検索
PGroonga keeps fast search
PGroongaは高速な検索を維持
PGroonga keeps index updated
PGroongaのインデックスは常に最新状態
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Index only scan
インデックスオンリースキャン
GIN: Not supported
GIN:未サポート
PGroonga: Supported
PGroonga:サポート
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
More faster search
より高速な検索
Direct Groonga search is
more faster
直接Groongaで検索するとさらに高速
Groonga: Full text search
engine PGroonga uses
Groonga:PGroongaが使っている全文検索エンジン
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Direct Groonga search
直接Groongaで検索
0
0.2
0.4
0.6
0.8
1
1.2
1.4
PostgreSQL OR MySQL database America
Data: English Wikipedia
(Many records and large docs)
N records: About 5.3millions
Average text size: 6.4KiB
Groonga is 30x faster than others
Elapsedtime(ms)
(Shorterisbetter)
Query
PGroonga Groonga textsearch
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Index creation time
インデックス作成時間
0
0.5
1
1.5
2
2.5
3
Data: English Wikipedia
Size: About 33GiB
Max text size: 1MiB
2x faster
than textsearch
Elapsedtime(hour)
(Shorterisbetter)
Module
Index creation
PGroonga textsearch pg_trgm
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Performance: Wrap up
性能:まとめ
Keep fast search w/ update
更新しながらでも高速検索を維持
Support index only scan
インデックスオンリースキャンをサポート
Direct Groonga search is
more faster
Groonga直接検索はもっと速い
Fast index creation
インデックス作成も速い
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Japanese specific feature
日本語向けの機能
Completion by Romaji
ローマ字による入力補完
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Completion: Table
入力補完:テーブル
CREATE TABLE stations (
name text,
readings text[]
-- ↑Support N readings
);
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Completion: Data
入力補完:データ
INSERT INTO stations VALUES
('Tokyo',
ARRAY['トウキョウ']),
-- ↑In Katakana
-- (...),
('Akihabara',
ARRAY['アキハバラ', 'アキバ']);
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Completion: Index
入力補完:インデックス
CREATE INDEX pgroonga_index
ON stations
USING pgroonga (
-- ↓For prefix and prefix Romaji/Katakana search
name pgroonga.text_term_search_ops_v2,
-- ↓For prefix and prefix Romaji/Katakana search
-- against array
readings pgroonga.text_array_term_search_ops_v2);
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Completion: Search
入力補完:検索
SELECT name, readings
FROM stations
WHERE name &^ 'tou' OR
-- ↑Prefix search
readings &^~> 'tou'
-- ↑Prefix Romaji/Katakana search
ORDER BY name LIMIT 10;
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Completion: Result
入力補完:結果
Hit by
prefix Romaji/Katakana search
"tou"(Romaji)→"トウ"(Katakana)
前方一致RK検索でヒット
name | readings
-------+--------------
Tokyo | {トウキョウ}
(1 row)
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
For Japanese: Wrap up
日本語向け機能:まとめ
Support prefix Romaji/Kana
search
前方一致RK検索をサポート
Useful for implementing auto
complete feature in search box
検索欄にオートコンプリート機能を実装する時に便利
Users don't need to convert
Romaji to Kanji
ユーザーはローマ字を漢字に変換する必要がない
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
JSON support
JSONサポート
Support full text search
全文検索対応
Target: All texts in JSON
JSON内のすべてのテキスト
Not only a text in a path
特定のパスのテキストだけではない
(GIN supports only this style)
(GINはこのやり方だけサポート)
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
JSON: FTS: Data
JSON:全文検索:Data
CREATE TABLE logs (
record jsonb
);
INSERT INTO logs (record)
VALUES ('{"host": "app1"}'),
('{"message": "app is down"}');
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
JSON: FTS: Index
JSON:全文検索:インデックス
CREATE INDEX message_index ON logs
USING GIN
((record->>'message') gin_trgm_ops);
-- {"message": "HERE IS ONLY SEARCHABLE"}
CREATE INDEX record_index ON logs
USING pgroonga (record);
-- All string values are searchable
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
JSON: FTS: GIN
JSON:全文検索:GIN
SELECT * FROM logs
WHERE record->>'message' LIKE '%app%';
-- ↑ {"host": "app1"} isn't target
-- record
-- ----------------------------
-- {"message": "app is down"}
-- (1 row)
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
JSON: FTS: PGroonga
JSON:全文検索:PGroonga
SELECT * FROM logs
WHERE record @@ 'string @ "app"';
-- ↑ All string values are target
-- record
-- ----------------------------
-- {"host": "app1"}
-- {"message": "app is down"}
-- (2 rows)
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
JSON: Wrap up
JSON:まとめ
Support full text search
against all texts in JSON
JSON内の全テキスト対象の全文検索をサポート
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Replication
レプリケーション
Support with PG 9.6!
PostgreSQL 9.6で使う場合はサポート!
PostgreSQL 9.6 ships
"generic WAL"
PostgreSQL 9.6で「generic WAL」機能が追加
Third party index can support
WAL generation
サードパーティーのインデックスもWALを生成できる
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Implementation
実装
Master: Encode action
logs as MessagePack
マスター:アクションログをMessagePack形式に変換
1.
Master: Write the action
logs to WAL
マスター:アクションログをWALに書き込み
2.
Slaves: Read the action
logs and apply them
スレーブ:アクションログを読み込んで適用
3.
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Overview
概要
Master PostgreSQL
Index file
PGroonga DB
INSERT PGroonga
Update
Append action logs
via generic WAL API
Action log
Slave
Apply pending action logs
on SELECT
SELECT
WAL
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Action log: "action"
アクションログ:「アクション」
{
"_action": ACTION_ID
}
# ACTION_ID: 0: INSERT
# ACTION_ID: 1: CREATE_TABLE
# ACTION_ID: 2: CREATE_COLUMN
# ACTION_ID: 3: SET_SOURCES
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Action log: INSERT
アクションログ:INSERT
{
"_action": 0,
"_table": "TABLE_NAME",
"ctid": PACKED_CTID_VALUE,
"column1": COLUMN1_VALUE,
...
}
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Action log: Logs
アクションログ:複数ログ
{"_action": ACTION_ID, ...}
{"_action": ACTION_ID, ...}
{"_action": ACTION_ID, ...}
...
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Write action logs
アクションログの書き込み
Index file Page
Header
Action
logs
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Apply action logs
アクションログの適用
Index file PGroonga DB
Applied offset
(Block#+Offset)
(2,10)
1 2
3 4
Apply
(2,50)
AfterBefore
10
50
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Action log: Why msgpack?
アクションログ:どうしてmsgpack?
Because MessagePack
supports streaming unpack
MessagePackはストリーミングで展開できるから
It's useful to stop applying
action logs when WAL is applied
partially on slaves
スレーブでWALが途中までしか書き込まれていないと
きにアクションログの適用を中断できるので便利
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Replication: Wrap up
レプリケーション:まとめ
Support with PG 9.6!
PostgreSQL 9.6で使う場合はサポート!
Concept: Action logs on WAL
コンセプト:WAL上にアクションログを書く
It'll be an useful pattern for
out of PostgreSQL storage index
PostgreSQL管理外のストレージを使うインデックスで
はこのパターンが使えるはず
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Wrap up1
まとめ1
PostgreSQL doesn't support
FTS for all languages
PostgreSQLの全文検索は一部の言語のみ対応
PGroonga supports FTS for
all languages
PGroongaの全文検索は全言語対応
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Wrap up2
まとめ2
PGroonga is fast stably
PGroongaは安定して速い
PGroonga supports FTS for
all texts in JSON
PGroongaはJSON中の全テキストに対する全文検索に対応
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Wrap up3
まとめ3
PGroonga supports
replication
PGroongaはレプリケーション対応
PostgreSQL 9.6 is required
ただしPostgreSQL 9.6が必要
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
Wrap up4
まとめ4
PGroonga makes PostgreSQL
fast full text search platform
for all languages!
PGroongaでPostgreSQLが
全言語対応高速全文検索プラットフォームになる!
PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0
See also
https://pgroonga.github.io/
Tutorial: /tutorial/
Install: /install/
Reference: /reference/
Includes replication doc and
benchmark docs
Community: /community/

More Related Content

What's hot

PostgreSQL 15 開発最新情報
PostgreSQL 15 開発最新情報PostgreSQL 15 開発最新情報
PostgreSQL 15 開発最新情報Masahiko Sawada
 
祝!PostgreSQLレプリケーション10周年!徹底紹介!!
祝!PostgreSQLレプリケーション10周年!徹底紹介!!祝!PostgreSQLレプリケーション10周年!徹底紹介!!
祝!PostgreSQLレプリケーション10周年!徹底紹介!!NTT DATA Technology & Innovation
 
オンライン物理バックアップの排他モードと非排他モードについて ~PostgreSQLバージョン15対応版~(第34回PostgreSQLアンカンファレンス...
オンライン物理バックアップの排他モードと非排他モードについて ~PostgreSQLバージョン15対応版~(第34回PostgreSQLアンカンファレンス...オンライン物理バックアップの排他モードと非排他モードについて ~PostgreSQLバージョン15対応版~(第34回PostgreSQLアンカンファレンス...
オンライン物理バックアップの排他モードと非排他モードについて ~PostgreSQLバージョン15対応版~(第34回PostgreSQLアンカンファレンス...NTT DATA Technology & Innovation
 
pg_bigm(ピージーバイグラム)を用いた全文検索のしくみ
pg_bigm(ピージーバイグラム)を用いた全文検索のしくみpg_bigm(ピージーバイグラム)を用いた全文検索のしくみ
pg_bigm(ピージーバイグラム)を用いた全文検索のしくみMasahiko Sawada
 
[B23] PostgreSQLのインデックス・チューニング by Tomonari Katsumata
[B23] PostgreSQLのインデックス・チューニング by Tomonari Katsumata[B23] PostgreSQLのインデックス・チューニング by Tomonari Katsumata
[B23] PostgreSQLのインデックス・チューニング by Tomonari KatsumataInsight Technology, Inc.
 
押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)
押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)
押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)NTT DATA Technology & Innovation
 
あなたの知らないPostgreSQL監視の世界
あなたの知らないPostgreSQL監視の世界あなたの知らないPostgreSQL監視の世界
あなたの知らないPostgreSQL監視の世界Yoshinori Nakanishi
 
PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...
PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...
PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...NTT DATA Technology & Innovation
 
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -onozaty
 
問合せ最適化インサイド
問合せ最適化インサイド問合せ最適化インサイド
問合せ最適化インサイドTakahiro Itagaki
 
アーキテクチャから理解するPostgreSQLのレプリケーション
アーキテクチャから理解するPostgreSQLのレプリケーションアーキテクチャから理解するPostgreSQLのレプリケーション
アーキテクチャから理解するPostgreSQLのレプリケーションMasahiko Sawada
 
オンライン物理バックアップの排他モードと非排他モードについて(第15回PostgreSQLアンカンファレンス@オンライン 発表資料)
オンライン物理バックアップの排他モードと非排他モードについて(第15回PostgreSQLアンカンファレンス@オンライン 発表資料)オンライン物理バックアップの排他モードと非排他モードについて(第15回PostgreSQLアンカンファレンス@オンライン 発表資料)
オンライン物理バックアップの排他モードと非排他モードについて(第15回PostgreSQLアンカンファレンス@オンライン 発表資料)NTT DATA Technology & Innovation
 
PostgreSQL 12は ここがスゴイ! ~性能改善やpluggable storage engineなどの新機能を徹底解説~ (NTTデータ テクノ...
PostgreSQL 12は ここがスゴイ! ~性能改善やpluggable storage engineなどの新機能を徹底解説~ (NTTデータ テクノ...PostgreSQL 12は ここがスゴイ! ~性能改善やpluggable storage engineなどの新機能を徹底解説~ (NTTデータ テクノ...
PostgreSQL 12は ここがスゴイ! ~性能改善やpluggable storage engineなどの新機能を徹底解説~ (NTTデータ テクノ...NTT DATA Technology & Innovation
 
PostgreSQLのリカバリ超入門(もしくはWAL、CHECKPOINT、オンラインバックアップの仕組み)
PostgreSQLのリカバリ超入門(もしくはWAL、CHECKPOINT、オンラインバックアップの仕組み)PostgreSQLのリカバリ超入門(もしくはWAL、CHECKPOINT、オンラインバックアップの仕組み)
PostgreSQLのリカバリ超入門(もしくはWAL、CHECKPOINT、オンラインバックアップの仕組み)Hironobu Suzuki
 
統計情報のリセットによるautovacuumへの影響について(第39回PostgreSQLアンカンファレンス@オンライン 発表資料)
統計情報のリセットによるautovacuumへの影響について(第39回PostgreSQLアンカンファレンス@オンライン 発表資料)統計情報のリセットによるautovacuumへの影響について(第39回PostgreSQLアンカンファレンス@オンライン 発表資料)
統計情報のリセットによるautovacuumへの影響について(第39回PostgreSQLアンカンファレンス@オンライン 発表資料)NTT DATA Technology & Innovation
 

What's hot (20)

Vacuum徹底解説
Vacuum徹底解説Vacuum徹底解説
Vacuum徹底解説
 
pg_bigmを用いた全文検索のしくみ(前編)
pg_bigmを用いた全文検索のしくみ(前編)pg_bigmを用いた全文検索のしくみ(前編)
pg_bigmを用いた全文検索のしくみ(前編)
 
PostgreSQLの運用・監視にまつわるエトセトラ
PostgreSQLの運用・監視にまつわるエトセトラPostgreSQLの運用・監視にまつわるエトセトラ
PostgreSQLの運用・監視にまつわるエトセトラ
 
使ってみませんか?pg_hint_plan
使ってみませんか?pg_hint_plan使ってみませんか?pg_hint_plan
使ってみませんか?pg_hint_plan
 
PostgreSQL 15 開発最新情報
PostgreSQL 15 開発最新情報PostgreSQL 15 開発最新情報
PostgreSQL 15 開発最新情報
 
祝!PostgreSQLレプリケーション10周年!徹底紹介!!
祝!PostgreSQLレプリケーション10周年!徹底紹介!!祝!PostgreSQLレプリケーション10周年!徹底紹介!!
祝!PostgreSQLレプリケーション10周年!徹底紹介!!
 
オンライン物理バックアップの排他モードと非排他モードについて ~PostgreSQLバージョン15対応版~(第34回PostgreSQLアンカンファレンス...
オンライン物理バックアップの排他モードと非排他モードについて ~PostgreSQLバージョン15対応版~(第34回PostgreSQLアンカンファレンス...オンライン物理バックアップの排他モードと非排他モードについて ~PostgreSQLバージョン15対応版~(第34回PostgreSQLアンカンファレンス...
オンライン物理バックアップの排他モードと非排他モードについて ~PostgreSQLバージョン15対応版~(第34回PostgreSQLアンカンファレンス...
 
pg_bigm(ピージーバイグラム)を用いた全文検索のしくみ
pg_bigm(ピージーバイグラム)を用いた全文検索のしくみpg_bigm(ピージーバイグラム)を用いた全文検索のしくみ
pg_bigm(ピージーバイグラム)を用いた全文検索のしくみ
 
[B23] PostgreSQLのインデックス・チューニング by Tomonari Katsumata
[B23] PostgreSQLのインデックス・チューニング by Tomonari Katsumata[B23] PostgreSQLのインデックス・チューニング by Tomonari Katsumata
[B23] PostgreSQLのインデックス・チューニング by Tomonari Katsumata
 
押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)
押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)
押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)
 
あなたの知らないPostgreSQL監視の世界
あなたの知らないPostgreSQL監視の世界あなたの知らないPostgreSQL監視の世界
あなたの知らないPostgreSQL監視の世界
 
PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...
PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...
PostgreSQLモニタリングの基本とNTTデータが追加したモニタリング新機能(Open Source Conference 2021 Online F...
 
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
 
問合せ最適化インサイド
問合せ最適化インサイド問合せ最適化インサイド
問合せ最適化インサイド
 
アーキテクチャから理解するPostgreSQLのレプリケーション
アーキテクチャから理解するPostgreSQLのレプリケーションアーキテクチャから理解するPostgreSQLのレプリケーション
アーキテクチャから理解するPostgreSQLのレプリケーション
 
オンライン物理バックアップの排他モードと非排他モードについて(第15回PostgreSQLアンカンファレンス@オンライン 発表資料)
オンライン物理バックアップの排他モードと非排他モードについて(第15回PostgreSQLアンカンファレンス@オンライン 発表資料)オンライン物理バックアップの排他モードと非排他モードについて(第15回PostgreSQLアンカンファレンス@オンライン 発表資料)
オンライン物理バックアップの排他モードと非排他モードについて(第15回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
PostgreSQL 12は ここがスゴイ! ~性能改善やpluggable storage engineなどの新機能を徹底解説~ (NTTデータ テクノ...
PostgreSQL 12は ここがスゴイ! ~性能改善やpluggable storage engineなどの新機能を徹底解説~ (NTTデータ テクノ...PostgreSQL 12は ここがスゴイ! ~性能改善やpluggable storage engineなどの新機能を徹底解説~ (NTTデータ テクノ...
PostgreSQL 12は ここがスゴイ! ~性能改善やpluggable storage engineなどの新機能を徹底解説~ (NTTデータ テクノ...
 
PostgreSQLのリカバリ超入門(もしくはWAL、CHECKPOINT、オンラインバックアップの仕組み)
PostgreSQLのリカバリ超入門(もしくはWAL、CHECKPOINT、オンラインバックアップの仕組み)PostgreSQLのリカバリ超入門(もしくはWAL、CHECKPOINT、オンラインバックアップの仕組み)
PostgreSQLのリカバリ超入門(もしくはWAL、CHECKPOINT、オンラインバックアップの仕組み)
 
pg_trgmと全文検索
pg_trgmと全文検索pg_trgmと全文検索
pg_trgmと全文検索
 
統計情報のリセットによるautovacuumへの影響について(第39回PostgreSQLアンカンファレンス@オンライン 発表資料)
統計情報のリセットによるautovacuumへの影響について(第39回PostgreSQLアンカンファレンス@オンライン 発表資料)統計情報のリセットによるautovacuumへの影響について(第39回PostgreSQLアンカンファレンス@オンライン 発表資料)
統計情報のリセットによるautovacuumへの影響について(第39回PostgreSQLアンカンファレンス@オンライン 発表資料)
 

Viewers also liked

Viewers also liked (14)

Resistencia aeróbica-Fartlek
Resistencia aeróbica-FartlekResistencia aeróbica-Fartlek
Resistencia aeróbica-Fartlek
 
Pranic Healing Center at the west of Aswan city
Pranic Healing Center at the west of Aswan cityPranic Healing Center at the west of Aswan city
Pranic Healing Center at the west of Aswan city
 
Slide 5
Slide 5Slide 5
Slide 5
 
Slide 10
Slide 10Slide 10
Slide 10
 
ITIL MGR
ITIL MGRITIL MGR
ITIL MGR
 
Mj decreto-355-cp
Mj decreto-355-cpMj decreto-355-cp
Mj decreto-355-cp
 
How to create bindings 2016
How to create bindings 2016How to create bindings 2016
How to create bindings 2016
 
educationa_recommendation_for JialiangLe
educationa_recommendation_for JialiangLeeducationa_recommendation_for JialiangLe
educationa_recommendation_for JialiangLe
 
2015 in reflection – locally and globally
2015 in reflection – locally and globally2015 in reflection – locally and globally
2015 in reflection – locally and globally
 
Medidas de promoção de saúde 6
Medidas de promoção de saúde 6Medidas de promoção de saúde 6
Medidas de promoção de saúde 6
 
Nichols MSIT Building
Nichols MSIT BuildingNichols MSIT Building
Nichols MSIT Building
 
Samudragupta ppt
Samudragupta pptSamudragupta ppt
Samudragupta ppt
 
Building Better Experiences With Content Personalization
Building Better Experiences With Content PersonalizationBuilding Better Experiences With Content Personalization
Building Better Experiences With Content Personalization
 
Texas policy 2016
Texas policy 2016Texas policy 2016
Texas policy 2016
 

Similar to PGroonga – Make PostgreSQL fast full text search platform for all languages!

PGroonga 2 – Make PostgreSQL rich full text search system backend!
PGroonga 2 – Make PostgreSQL rich full text search system backend!PGroonga 2 – Make PostgreSQL rich full text search system backend!
PGroonga 2 – Make PostgreSQL rich full text search system backend!Kouhei Sutou
 
Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga-
Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga-Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga-
Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga-Hiroshi Yuki
 
gRPC or Rest, why not both?
gRPC or Rest, why not both?gRPC or Rest, why not both?
gRPC or Rest, why not both?Mohammad Murad
 
Useful PostgreSQL Extensions
Useful PostgreSQL ExtensionsUseful PostgreSQL Extensions
Useful PostgreSQL ExtensionsEDB
 
gRPC 프레임워크를 만들며 알아보는 파이썬 - 파이콘2020
gRPC 프레임워크를 만들며 알아보는 파이썬  - 파이콘2020gRPC 프레임워크를 만들며 알아보는 파이썬  - 파이콘2020
gRPC 프레임워크를 만들며 알아보는 파이썬 - 파이콘2020재현 신
 
pgpool: Features and Development
pgpool: Features and Developmentpgpool: Features and Development
pgpool: Features and Developmentelliando dias
 
Modern javascript localization with c-3po and the good old gettext
Modern javascript localization with c-3po and the good old gettextModern javascript localization with c-3po and the good old gettext
Modern javascript localization with c-3po and the good old gettextAlexander Mostovenko
 
Whats wrong with postgres | PGConf EU 2019 | Craig Kerstiens
Whats wrong with postgres | PGConf EU 2019 | Craig KerstiensWhats wrong with postgres | PGConf EU 2019 | Craig Kerstiens
Whats wrong with postgres | PGConf EU 2019 | Craig KerstiensCitus Data
 
OSMC 2008 | PostgreSQL Monitoring - Introduction, Internals And Monitoring S...
OSMC 2008 |  PostgreSQL Monitoring - Introduction, Internals And Monitoring S...OSMC 2008 |  PostgreSQL Monitoring - Introduction, Internals And Monitoring S...
OSMC 2008 | PostgreSQL Monitoring - Introduction, Internals And Monitoring S...NETWAYS
 
When it all GOes right
When it all GOes rightWhen it all GOes right
When it all GOes rightPavlo Golub
 
A gentle intro to Golang and the Go-universe
A gentle intro to Golang and the Go-universeA gentle intro to Golang and the Go-universe
A gentle intro to Golang and the Go-universeAlex-P. Natsios
 
GStreamer 101
GStreamer 101GStreamer 101
GStreamer 101yuvipanda
 
PostgreSQL HA
PostgreSQL   HAPostgreSQL   HA
PostgreSQL HAharoonm
 
Big data beyond the JVM - DDTX 2018
Big data beyond the JVM -  DDTX 2018Big data beyond the JVM -  DDTX 2018
Big data beyond the JVM - DDTX 2018Holden Karau
 

Similar to PGroonga – Make PostgreSQL fast full text search platform for all languages! (20)

PGroonga & Zulip
PGroonga & ZulipPGroonga & Zulip
PGroonga & Zulip
 
PGroonga 2 – Make PostgreSQL rich full text search system backend!
PGroonga 2 – Make PostgreSQL rich full text search system backend!PGroonga 2 – Make PostgreSQL rich full text search system backend!
PGroonga 2 – Make PostgreSQL rich full text search system backend!
 
Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga-
Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga-Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga-
Fast fulltext search in Ruby, without Java -Groonga, Rroonga and Droonga-
 
gRPC or Rest, why not both?
gRPC or Rest, why not both?gRPC or Rest, why not both?
gRPC or Rest, why not both?
 
Useful PostgreSQL Extensions
Useful PostgreSQL ExtensionsUseful PostgreSQL Extensions
Useful PostgreSQL Extensions
 
gRPC 프레임워크를 만들며 알아보는 파이썬 - 파이콘2020
gRPC 프레임워크를 만들며 알아보는 파이썬  - 파이콘2020gRPC 프레임워크를 만들며 알아보는 파이썬  - 파이콘2020
gRPC 프레임워크를 만들며 알아보는 파이썬 - 파이콘2020
 
pgpool: Features and Development
pgpool: Features and Developmentpgpool: Features and Development
pgpool: Features and Development
 
Modern javascript localization with c-3po and the good old gettext
Modern javascript localization with c-3po and the good old gettextModern javascript localization with c-3po and the good old gettext
Modern javascript localization with c-3po and the good old gettext
 
Whats wrong with postgres | PGConf EU 2019 | Craig Kerstiens
Whats wrong with postgres | PGConf EU 2019 | Craig KerstiensWhats wrong with postgres | PGConf EU 2019 | Craig Kerstiens
Whats wrong with postgres | PGConf EU 2019 | Craig Kerstiens
 
OSMC 2008 | PostgreSQL Monitoring - Introduction, Internals And Monitoring S...
OSMC 2008 |  PostgreSQL Monitoring - Introduction, Internals And Monitoring S...OSMC 2008 |  PostgreSQL Monitoring - Introduction, Internals And Monitoring S...
OSMC 2008 | PostgreSQL Monitoring - Introduction, Internals And Monitoring S...
 
When it all GOes right
When it all GOes rightWhen it all GOes right
When it all GOes right
 
A gentle intro to Golang and the Go-universe
A gentle intro to Golang and the Go-universeA gentle intro to Golang and the Go-universe
A gentle intro to Golang and the Go-universe
 
GStreamer 101
GStreamer 101GStreamer 101
GStreamer 101
 
Pywps
PywpsPywps
Pywps
 
PostgreSQL HA
PostgreSQL   HAPostgreSQL   HA
PostgreSQL HA
 
Learn python
Learn pythonLearn python
Learn python
 
Ruby - The Hard Bits
Ruby - The Hard BitsRuby - The Hard Bits
Ruby - The Hard Bits
 
Fisl13 gstreamer
Fisl13 gstreamerFisl13 gstreamer
Fisl13 gstreamer
 
Big data beyond the JVM - DDTX 2018
Big data beyond the JVM -  DDTX 2018Big data beyond the JVM -  DDTX 2018
Big data beyond the JVM - DDTX 2018
 
SFScon 2020 - Matteo Ghetta - DataPlotly - D3-like plots in QGIS
SFScon 2020 - Matteo Ghetta - DataPlotly - D3-like plots in QGISSFScon 2020 - Matteo Ghetta - DataPlotly - D3-like plots in QGIS
SFScon 2020 - Matteo Ghetta - DataPlotly - D3-like plots in QGIS
 

More from Kouhei Sutou

RubyKaigi 2022 - Fast data processing with Ruby and Apache Arrow
RubyKaigi 2022 - Fast data processing with Ruby and Apache ArrowRubyKaigi 2022 - Fast data processing with Ruby and Apache Arrow
RubyKaigi 2022 - Fast data processing with Ruby and Apache ArrowKouhei Sutou
 
Apache Arrow Flight – ビッグデータ用高速データ転送フレームワーク #dbts2021
Apache Arrow Flight – ビッグデータ用高速データ転送フレームワーク #dbts2021Apache Arrow Flight – ビッグデータ用高速データ転送フレームワーク #dbts2021
Apache Arrow Flight – ビッグデータ用高速データ転送フレームワーク #dbts2021Kouhei Sutou
 
RubyKaigi Takeout 2021 - Red Arrow - Ruby and Apache Arrow
RubyKaigi Takeout 2021 - Red Arrow - Ruby and Apache ArrowRubyKaigi Takeout 2021 - Red Arrow - Ruby and Apache Arrow
RubyKaigi Takeout 2021 - Red Arrow - Ruby and Apache ArrowKouhei Sutou
 
Rubyと仕事と自由なソフトウェア
Rubyと仕事と自由なソフトウェアRubyと仕事と自由なソフトウェア
Rubyと仕事と自由なソフトウェアKouhei Sutou
 
Apache Arrowフォーマットはなぜ速いのか
Apache Arrowフォーマットはなぜ速いのかApache Arrowフォーマットはなぜ速いのか
Apache Arrowフォーマットはなぜ速いのかKouhei Sutou
 
Apache Arrow 1.0 - A cross-language development platform for in-memory data
Apache Arrow 1.0 - A cross-language development platform for in-memory dataApache Arrow 1.0 - A cross-language development platform for in-memory data
Apache Arrow 1.0 - A cross-language development platform for in-memory dataKouhei Sutou
 
Redmine検索の未来像
Redmine検索の未来像Redmine検索の未来像
Redmine検索の未来像Kouhei Sutou
 
Apache Arrow - A cross-language development platform for in-memory data
Apache Arrow - A cross-language development platform for in-memory dataApache Arrow - A cross-language development platform for in-memory data
Apache Arrow - A cross-language development platform for in-memory dataKouhei Sutou
 
Better CSV processing with Ruby 2.6
Better CSV processing with Ruby 2.6Better CSV processing with Ruby 2.6
Better CSV processing with Ruby 2.6Kouhei Sutou
 
Apache Arrow - データ処理ツールの次世代プラットフォーム
Apache Arrow - データ処理ツールの次世代プラットフォームApache Arrow - データ処理ツールの次世代プラットフォーム
Apache Arrow - データ処理ツールの次世代プラットフォームKouhei Sutou
 
MySQL・PostgreSQLだけで作る高速あいまい全文検索システム
MySQL・PostgreSQLだけで作る高速あいまい全文検索システムMySQL・PostgreSQLだけで作る高速あいまい全文検索システム
MySQL・PostgreSQLだけで作る高速あいまい全文検索システムKouhei Sutou
 
MySQL 8.0でMroonga
MySQL 8.0でMroongaMySQL 8.0でMroonga
MySQL 8.0でMroongaKouhei Sutou
 
Mroongaの高速全文検索機能でWordPress内のコンテンツを有効活用!
Mroongaの高速全文検索機能でWordPress内のコンテンツを有効活用!Mroongaの高速全文検索機能でWordPress内のコンテンツを有効活用!
Mroongaの高速全文検索機能でWordPress内のコンテンツを有効活用!Kouhei Sutou
 
MariaDBとMroongaで作る全言語対応超高速全文検索システム
MariaDBとMroongaで作る全言語対応超高速全文検索システムMariaDBとMroongaで作る全言語対応超高速全文検索システム
MariaDBとMroongaで作る全言語対応超高速全文検索システムKouhei Sutou
 
PGroonga 2 - PostgreSQLでの全文検索の決定版
PGroonga 2 - PostgreSQLでの全文検索の決定版PGroonga 2 - PostgreSQLでの全文検索の決定版
PGroonga 2 - PostgreSQLでの全文検索の決定版Kouhei Sutou
 

More from Kouhei Sutou (20)

RubyKaigi 2022 - Fast data processing with Ruby and Apache Arrow
RubyKaigi 2022 - Fast data processing with Ruby and Apache ArrowRubyKaigi 2022 - Fast data processing with Ruby and Apache Arrow
RubyKaigi 2022 - Fast data processing with Ruby and Apache Arrow
 
Apache Arrow Flight – ビッグデータ用高速データ転送フレームワーク #dbts2021
Apache Arrow Flight – ビッグデータ用高速データ転送フレームワーク #dbts2021Apache Arrow Flight – ビッグデータ用高速データ転送フレームワーク #dbts2021
Apache Arrow Flight – ビッグデータ用高速データ転送フレームワーク #dbts2021
 
RubyKaigi Takeout 2021 - Red Arrow - Ruby and Apache Arrow
RubyKaigi Takeout 2021 - Red Arrow - Ruby and Apache ArrowRubyKaigi Takeout 2021 - Red Arrow - Ruby and Apache Arrow
RubyKaigi Takeout 2021 - Red Arrow - Ruby and Apache Arrow
 
Rubyと仕事と自由なソフトウェア
Rubyと仕事と自由なソフトウェアRubyと仕事と自由なソフトウェア
Rubyと仕事と自由なソフトウェア
 
Apache Arrowフォーマットはなぜ速いのか
Apache Arrowフォーマットはなぜ速いのかApache Arrowフォーマットはなぜ速いのか
Apache Arrowフォーマットはなぜ速いのか
 
Apache Arrow 1.0 - A cross-language development platform for in-memory data
Apache Arrow 1.0 - A cross-language development platform for in-memory dataApache Arrow 1.0 - A cross-language development platform for in-memory data
Apache Arrow 1.0 - A cross-language development platform for in-memory data
 
Apache Arrow 2019
Apache Arrow 2019Apache Arrow 2019
Apache Arrow 2019
 
Redmine検索の未来像
Redmine検索の未来像Redmine検索の未来像
Redmine検索の未来像
 
Apache Arrow - A cross-language development platform for in-memory data
Apache Arrow - A cross-language development platform for in-memory dataApache Arrow - A cross-language development platform for in-memory data
Apache Arrow - A cross-language development platform for in-memory data
 
Better CSV processing with Ruby 2.6
Better CSV processing with Ruby 2.6Better CSV processing with Ruby 2.6
Better CSV processing with Ruby 2.6
 
Apache Arrow
Apache ArrowApache Arrow
Apache Arrow
 
Apache Arrow - データ処理ツールの次世代プラットフォーム
Apache Arrow - データ処理ツールの次世代プラットフォームApache Arrow - データ処理ツールの次世代プラットフォーム
Apache Arrow - データ処理ツールの次世代プラットフォーム
 
Apache Arrow
Apache ArrowApache Arrow
Apache Arrow
 
MySQL・PostgreSQLだけで作る高速あいまい全文検索システム
MySQL・PostgreSQLだけで作る高速あいまい全文検索システムMySQL・PostgreSQLだけで作る高速あいまい全文検索システム
MySQL・PostgreSQLだけで作る高速あいまい全文検索システム
 
MySQL 8.0でMroonga
MySQL 8.0でMroongaMySQL 8.0でMroonga
MySQL 8.0でMroonga
 
My way with Ruby
My way with RubyMy way with Ruby
My way with Ruby
 
Red Data Tools
Red Data ToolsRed Data Tools
Red Data Tools
 
Mroongaの高速全文検索機能でWordPress内のコンテンツを有効活用!
Mroongaの高速全文検索機能でWordPress内のコンテンツを有効活用!Mroongaの高速全文検索機能でWordPress内のコンテンツを有効活用!
Mroongaの高速全文検索機能でWordPress内のコンテンツを有効活用!
 
MariaDBとMroongaで作る全言語対応超高速全文検索システム
MariaDBとMroongaで作る全言語対応超高速全文検索システムMariaDBとMroongaで作る全言語対応超高速全文検索システム
MariaDBとMroongaで作る全言語対応超高速全文検索システム
 
PGroonga 2 - PostgreSQLでの全文検索の決定版
PGroonga 2 - PostgreSQLでの全文検索の決定版PGroonga 2 - PostgreSQLでの全文検索の決定版
PGroonga 2 - PostgreSQLでの全文検索の決定版
 

PGroonga – Make PostgreSQL fast full text search platform for all languages!

  • 1. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 PGroongaMake PostgreSQL fast full text search platform for all languages! Kouhei Sutou ClearCode Inc. PGConf.ASIA 2016 2016-12-03
  • 2. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 PostgreSQL and me PostgreSQLと私 Some my patches are mergedいくつかパッチがマージされている
  • 3. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Patches パッチ #13840: pg_dump generates unloadable SQL pg_dumpがリストアできないSQLを出力する #14160: DROP ACCESS METHOD IF EXISTS isn't impl. DROP ACCESS METHOD IF EXISTSが実装されていない They are found while developing PGroonga どちらもPGroonga開発中に見つけた問題
  • 4. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 PGroonga dev style PGroongaの開発スタイル When there are problems in related projects including PostgreSQL PostgreSQLを含む関連プロジェクトに問題があった場合 We fix these problems in these projects instead of choosing workaround in PGroonga PGroonga側で回避するのではなく 関連プロジェクトの方で問題を直す
  • 5. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 PostgreSQL and FTS PostgreSQLと全文検索 PostgreSQL has built-in full text search feature PostgreSQLには組込の全文検索機能がある It has some problems... ただ、いくつか問題がある We fixed them by PGroonga PGroongaを開発することでそれらの問題を修正した instead of fixing PostgreSQL 😓 PostgreSQLを修正するのではなくて…
  • 6. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Because... 理由は… Our approach is different from PostgreSQL's approach PGroongaのやり方はPostgreSQLのやり方と違う 1. PG provides plugin system PostgreSQLはプラグインの仕組みを提供している Implementing as a plugin is PostgreSQL way! プラグインでの実装はPostgreSQLらしいやり方! 2.
  • 7. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 PG FTS problem PostgreSQLの全文検索の問題 Many langs aren't supported サポートしていない言語がたくさんある e.g.: Asian languages 例:アジアの言語 Japanese, Chinese and more 日本語や中国語など
  • 8. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 FTS for Japanese1 日本語の全文検索1 SELECT to_tsvector('japanese', 'こんにちは'); -- ERROR: text search configuration -- "japanese" does not exist -- LINE 2: to_tsvector('japanese', -- ^
  • 9. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 FTS for Japanese2 日本語の全文検索2 CREATE EXTENSION pg_trgm; SELECT show_trgm('こんにちは'); -- show_trgm -- ----------- -- {} ← Must not empty! -- (1 row)
  • 10. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Existing solution 既存の解決策 pg_bigm
  • 11. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 pg_bigm An extension 拡張機能 Similar to pg_trgm pg_trgmと似ている Operator class for GIN GIN用の演算子クラス
  • 12. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 pg_bigm: Usage pg_bigm:使い方 CREATE INDEX index ON table USING GIN (column gin_bigm_ops); -- ↑Use GIN ↑Specify op class
  • 13. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 pg_bigm: Demerit pg_bigm:デメリット Slow for large document 文書が長いと遅い (Normally, we want to use FTS for large document) (普通は長い文書に対して全文検索したい) Because it needs "recheck" 「recheck」が必要だから
  • 14. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 "recheck" "Exact" seq. search after "loose" index search 「ゆるい」インデックス検索の後に実行する 「正確な」シーケンシャルサーチ The larger text, the slower 対象テキストが大きければ大きいほど遅くなる text = doc size * N docs 対象テキスト = 文書サイズ * 文書数
  • 15. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Benchmark ベンチマーク 0 0.5 1 1.5 2 2.5 3 311 14706 20389 Data: Japanese Wikipedia (Many records and large documents) N records: About 0.9millions Average text size: 6.7KiB Slow Slow Elapsedtime(sec) (Lowerisbetter) N hits pg_bigm
  • 16. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 New solution 新しい解決策
  • 17. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 PGroonga Pronunciation: píːzí:lúnɡά 読み方:ぴーじーるんが An extension 拡張機能 Index and operator classes インデックスと演算子クラス Not operator classes for GIN GINの演算子クラスではない
  • 18. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 PGroonga layer GIN textsearch pg_trgm pg_bigm Index Operator class PGroonga PGroonga
  • 19. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Benchmark ベンチマーク 0 0.5 1 1.5 2 2.5 3 311 14706 20389 Data: Japanese Wikipedia (Many records and large documents) N records: About 0.9millions Average text size: 6.7KiB Fast Fast Elapsedtime(sec) (Lowerisbetter) N hits PGroonga pg_bigm
  • 20. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Wrap up1 まとめ1 PostgreSQL doesn't support Asian languages PostgreSQLはアジアの言語をサポートしていない pg_bigm and PGroonga support all languages pg_bigmとPGroongaはすべての言語をサポートしている
  • 21. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Wrap up2 まとめ2 Many hits case: ヒット数が多い場合 pg_bigm is slow pg_bigmは遅い PGroonga is fast PGroongaは速い
  • 22. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Why is PGroonga fast? PGroongaはどうして速いのか Doesn't need "recheck" 「recheck」が必要ないから Is "recheck" really slow? 本当に「recheck」が遅いの? See one more benchmark result もう一つベンチマーク結果を見てみましょう
  • 23. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Benchmark ベンチマーク 0 0.5 1 1.5 2 2.5 3 0 100000 200000 300000 400000 500000 Data: Japanese Wikipedia (Many records and large documents) N records: About 0.9millions Average text size: 6.7KiB Slow Slow Fast for many hits! Query: "日本" Elapsedtime(sec) (Lowerisbetter) N hits PGroonga pg_bigm
  • 24. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Why is pg_bigm fast? pg_bigmはどうして速いのか Query is "日本" クエリーは「日本」 Point: 2 characters ポイント:2文字 pg_bigm doesn't need "recheck" for 2 chars query pg_bigmは2文字のクエリーに「recheck」の必要がない It means that "recheck" is slow つまり「recheck」が遅いということ
  • 25. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 N-gram and "recheck" N-gramと「recheck」 N-gram approach needs "phrase search" when query has N+1 or more characters N+1文字以上のクエリーには「フレーズ検索」が必要 N=2 for pg_bigm, N=3 for pg_trgm pg_bigmはN=2でpg_trgmはN=3 GIN needs "recheck" for "phrase search" GINは「フレーズ検索」には「recheck」が必要
  • 26. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Phrase search フレーズ検索 Phrase search is "token search" and "position check" フレーズ検索は「トークン検索」と「位置チェック」 Tokens must exist and be ordered トークンは同じ順序で出現していないといけない OK: "car at" for "car at" query NG: "at car" for "car at" query
  • 27. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 N-gram and phrase search Split text to tokens テキストをトークンに分割 "cat"→"ca","at" 1. Search all tokens すべてのトークンを検索 "ca" & "at" exist: Candidate! 2. Check appearance pos. 出現位置をチェック "ca" then "at": Found! 3.
  • 28. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 N-gram and GIN: Create N-gramとGIN:作成 GIN "ca","at" Tokenize Documents cat at car 10 20 ID Text "ca" "at" "t " Token Posting list 10,20 10,20 20 " c" "ar" 20 20 "at","t "," c","ca","ar"
  • 29. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 N-gram and GIN: Search N-gramとGIN:検索 "ca" "at" "t " Token Posting list GIN 10,20 10,20 20 cat Query "ca","at" Tokenize AND cat at car 10 20 Documents ID Text 10,20 Candidates" c" "ar" 20 20 Search Appearance position check (Point: Out of GIN)
  • 30. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 GIN and phrase search GINとフレーズ検索 Phrase search needs position check フレーズ検索では出現位置チェックが必要 GIN doesn't support position check GINは出現位置チェックをサポートしていない →GIN needs "recheck"→Slow! GINでは「recheck」が必要だから遅い
  • 31. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Why is PGroonga fast? PGroongaはどうして速いのか PGroonga uses N-gram by default PGroongaはデフォルトでN-gramを使っている But doesn't need "recheck" PGroongaは「recheck」の必要がない
  • 32. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Why no "recheck"? どうして「recheck」が必要ないのか PGroonga uses full inverted indexPGroongaは完全転置インデックスを使っているから
  • 33. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Full inverted index 完全転置インデックス Including position位置情報を含む
  • 34. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Inverted index diff 転置インデックスの違い cat at car 10 20 Documents Full: Doc ID + pos "ca" "at" "t " ID Text Token Posting list 20:2 10:2,20:1 10:1,20:4 "ca","at" 1 2 "at","t "," c","ca","ar" 1 2 3 4 5 Tokenize Not full: Only doc ID " c" "ar" 20:3 20:5 "ca" "at" "t " Token Posting list 20 10,20 10,20 " c" "ar" 20 20
  • 35. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 N-gram/PGroonga: Search N-gramとPGroonga:検索 "ca" "at" "t " Token Posting list PGroonga 10:1,20:4 10:2,20:1 20:2 cat Query Tokenize AND cat at car 10 20 Documents ID Text 10 Result " c" "ar" 20:3 20:5 Search Appearance position check (Point: In PGroonga) "ca","at"
  • 36. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Wrap up まとめ N-gram needs phrase search N-gramの場合はフレーズ検索が必要 Full inverted index provides fast phrase search 完全転置インデックスを使うと高速にフレーズ検索でき る GIN isn't full inverted index GINは完全転置インデックスではない PGroonga uses full inverted index PGroongaは完全転置インデックスを使っている
  • 37. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 FTS and English(*) 全文検索と英語 Normally, N-gram isn't used for English FTS 普通は英語の全文検索にN-gramを使わない N-gram is slower than word based approach (textsearch approach) N-gramは単語ベースのやり方(textsearchのやり方) より遅め Stemming/stop word can't be used N-gramではステミングとストップワードを使えない (*) English≒Alphabet based languages
  • 38. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 PGroonga and English PGroongaと英語 PGroonga uses N-gram by default PGroongaはデフォルトではN-gramを使う Is PGroonga slow for English? ではPGroongaは英語では遅いのか? No. Similar to textsearch 遅くない。textsearchと同じくらい
  • 39. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 PGroonga: Search PGroonga:検索 0 0.2 0.4 0.6 0.8 1 1.2 1.4 PostgreSQL OR MySQL database America Data: English Wikipedia (Many records and large docs) N records: About 5.3millions Average text size: 6.4KiB Elapsedtime(ms) (Shorterisbetter) Query PGroonga textsearch
  • 40. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 PGroonga's N-gram Variable size N-gram 可変長サイズのN-gram Continuous alphabets are 1 token (= word based approach) 連続したアルファベットは1トークン(=単語ベース) Hello→"Hello" not "He","el",… No alphabet is 2-gram 非アルファベットは2-gram こんにちは→"こん","んに",…
  • 41. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Wrap up1 まとめ1 PGroonga's search is fast for all languages PGroongaの検索はすべての言語で速い Including alphabet based languages and Asian languages mixed case アルファベットベースの言語とアジアの言語が混ざっ た場合でも速い (textsearch doesn't support mixed case) (textsearchは言語を混ぜることはできない)
  • 42. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Wrap up2 まとめ2 PGroonga makes PostgreSQL fast full text search platform for all languages! PGroongaでPostgreSQLが 全言語対応高速全文検索プラットフォームになる!
  • 43. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 More about PGroonga PGroongaについてもっと Performance 性能 Japanese specific feature 日本語向けの機能 JSON support JSONサポート Replication レプリケーション
  • 44. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Performance 性能 Search and update 検索と更新 Index only scan インデックスオンリースキャン Direct Groonga search 直接Groongaで検索 Index creation インデックス作成
  • 45. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Search and update 検索と更新 Doesn't decrease search performance while updating 更新中も検索性能が落ちない It's good characteristics for chat application チャットアプリでうれしい傾向 Zulip supports PGroonga Zulip: OSS chat app by Dropbox ZulipはPGroongaをサポートしている ZulipはDropboxが開発しているOSSのチャットアプリ
  • 46. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Characteristics 傾向 Searchthroughput Update throughput PGroonga Searchthroughput Update throughput GIN Keep search performance while many updates Decrease search performance while updating
  • 47. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Update and lock 更新とロック Update without read locks 参照ロックなしで更新 Write locks are required 書き込みロックは必要
  • 48. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 GIN: Read/Write GIN:読み書き Conn1 Conn2 INSERT start SELECT start Blocked INSERT finish SELECT finish GIN Slow down!
  • 49. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 PGroonga: Read/Write PGroonga:読み書き Conn1 Conn2 INSERT start SELECT start INSERT finish SELECT finish PGroonga No slow down!
  • 50. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Fast stably 安定して速い GIN has intermittent performance decrements GINは間欠的な性能劣化がある For details:🔎"GIN pending list" 詳細は「GIN pending list」で検索 PGroonga keeps fast search PGroongaは高速な検索を維持 PGroonga keeps index updated PGroongaのインデックスは常に最新状態
  • 51. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Index only scan インデックスオンリースキャン GIN: Not supported GIN:未サポート PGroonga: Supported PGroonga:サポート
  • 52. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 More faster search より高速な検索 Direct Groonga search is more faster 直接Groongaで検索するとさらに高速 Groonga: Full text search engine PGroonga uses Groonga:PGroongaが使っている全文検索エンジン
  • 53. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Direct Groonga search 直接Groongaで検索 0 0.2 0.4 0.6 0.8 1 1.2 1.4 PostgreSQL OR MySQL database America Data: English Wikipedia (Many records and large docs) N records: About 5.3millions Average text size: 6.4KiB Groonga is 30x faster than others Elapsedtime(ms) (Shorterisbetter) Query PGroonga Groonga textsearch
  • 54. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Index creation time インデックス作成時間 0 0.5 1 1.5 2 2.5 3 Data: English Wikipedia Size: About 33GiB Max text size: 1MiB 2x faster than textsearch Elapsedtime(hour) (Shorterisbetter) Module Index creation PGroonga textsearch pg_trgm
  • 55. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Performance: Wrap up 性能:まとめ Keep fast search w/ update 更新しながらでも高速検索を維持 Support index only scan インデックスオンリースキャンをサポート Direct Groonga search is more faster Groonga直接検索はもっと速い Fast index creation インデックス作成も速い
  • 56. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Japanese specific feature 日本語向けの機能 Completion by Romaji ローマ字による入力補完
  • 57. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Completion: Table 入力補完:テーブル CREATE TABLE stations ( name text, readings text[] -- ↑Support N readings );
  • 58. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Completion: Data 入力補完:データ INSERT INTO stations VALUES ('Tokyo', ARRAY['トウキョウ']), -- ↑In Katakana -- (...), ('Akihabara', ARRAY['アキハバラ', 'アキバ']);
  • 59. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Completion: Index 入力補完:インデックス CREATE INDEX pgroonga_index ON stations USING pgroonga ( -- ↓For prefix and prefix Romaji/Katakana search name pgroonga.text_term_search_ops_v2, -- ↓For prefix and prefix Romaji/Katakana search -- against array readings pgroonga.text_array_term_search_ops_v2);
  • 60. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Completion: Search 入力補完:検索 SELECT name, readings FROM stations WHERE name &^ 'tou' OR -- ↑Prefix search readings &^~> 'tou' -- ↑Prefix Romaji/Katakana search ORDER BY name LIMIT 10;
  • 61. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Completion: Result 入力補完:結果 Hit by prefix Romaji/Katakana search "tou"(Romaji)→"トウ"(Katakana) 前方一致RK検索でヒット name | readings -------+-------------- Tokyo | {トウキョウ} (1 row)
  • 62. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 For Japanese: Wrap up 日本語向け機能:まとめ Support prefix Romaji/Kana search 前方一致RK検索をサポート Useful for implementing auto complete feature in search box 検索欄にオートコンプリート機能を実装する時に便利 Users don't need to convert Romaji to Kanji ユーザーはローマ字を漢字に変換する必要がない
  • 63. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 JSON support JSONサポート Support full text search 全文検索対応 Target: All texts in JSON JSON内のすべてのテキスト Not only a text in a path 特定のパスのテキストだけではない (GIN supports only this style) (GINはこのやり方だけサポート)
  • 64. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 JSON: FTS: Data JSON:全文検索:Data CREATE TABLE logs ( record jsonb ); INSERT INTO logs (record) VALUES ('{"host": "app1"}'), ('{"message": "app is down"}');
  • 65. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 JSON: FTS: Index JSON:全文検索:インデックス CREATE INDEX message_index ON logs USING GIN ((record->>'message') gin_trgm_ops); -- {"message": "HERE IS ONLY SEARCHABLE"} CREATE INDEX record_index ON logs USING pgroonga (record); -- All string values are searchable
  • 66. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 JSON: FTS: GIN JSON:全文検索:GIN SELECT * FROM logs WHERE record->>'message' LIKE '%app%'; -- ↑ {"host": "app1"} isn't target -- record -- ---------------------------- -- {"message": "app is down"} -- (1 row)
  • 67. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 JSON: FTS: PGroonga JSON:全文検索:PGroonga SELECT * FROM logs WHERE record @@ 'string @ "app"'; -- ↑ All string values are target -- record -- ---------------------------- -- {"host": "app1"} -- {"message": "app is down"} -- (2 rows)
  • 68. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 JSON: Wrap up JSON:まとめ Support full text search against all texts in JSON JSON内の全テキスト対象の全文検索をサポート
  • 69. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Replication レプリケーション Support with PG 9.6! PostgreSQL 9.6で使う場合はサポート! PostgreSQL 9.6 ships "generic WAL" PostgreSQL 9.6で「generic WAL」機能が追加 Third party index can support WAL generation サードパーティーのインデックスもWALを生成できる
  • 70. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Implementation 実装 Master: Encode action logs as MessagePack マスター:アクションログをMessagePack形式に変換 1. Master: Write the action logs to WAL マスター:アクションログをWALに書き込み 2. Slaves: Read the action logs and apply them スレーブ:アクションログを読み込んで適用 3.
  • 71. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Overview 概要 Master PostgreSQL Index file PGroonga DB INSERT PGroonga Update Append action logs via generic WAL API Action log Slave Apply pending action logs on SELECT SELECT WAL
  • 72. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Action log: "action" アクションログ:「アクション」 { "_action": ACTION_ID } # ACTION_ID: 0: INSERT # ACTION_ID: 1: CREATE_TABLE # ACTION_ID: 2: CREATE_COLUMN # ACTION_ID: 3: SET_SOURCES
  • 73. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Action log: INSERT アクションログ:INSERT { "_action": 0, "_table": "TABLE_NAME", "ctid": PACKED_CTID_VALUE, "column1": COLUMN1_VALUE, ... }
  • 74. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Action log: Logs アクションログ:複数ログ {"_action": ACTION_ID, ...} {"_action": ACTION_ID, ...} {"_action": ACTION_ID, ...} ...
  • 75. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Write action logs アクションログの書き込み Index file Page Header Action logs
  • 76. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Apply action logs アクションログの適用 Index file PGroonga DB Applied offset (Block#+Offset) (2,10) 1 2 3 4 Apply (2,50) AfterBefore 10 50
  • 77. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Action log: Why msgpack? アクションログ:どうしてmsgpack? Because MessagePack supports streaming unpack MessagePackはストリーミングで展開できるから It's useful to stop applying action logs when WAL is applied partially on slaves スレーブでWALが途中までしか書き込まれていないと きにアクションログの適用を中断できるので便利
  • 78. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Replication: Wrap up レプリケーション:まとめ Support with PG 9.6! PostgreSQL 9.6で使う場合はサポート! Concept: Action logs on WAL コンセプト:WAL上にアクションログを書く It'll be an useful pattern for out of PostgreSQL storage index PostgreSQL管理外のストレージを使うインデックスで はこのパターンが使えるはず
  • 79. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Wrap up1 まとめ1 PostgreSQL doesn't support FTS for all languages PostgreSQLの全文検索は一部の言語のみ対応 PGroonga supports FTS for all languages PGroongaの全文検索は全言語対応
  • 80. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Wrap up2 まとめ2 PGroonga is fast stably PGroongaは安定して速い PGroonga supports FTS for all texts in JSON PGroongaはJSON中の全テキストに対する全文検索に対応
  • 81. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Wrap up3 まとめ3 PGroonga supports replication PGroongaはレプリケーション対応 PostgreSQL 9.6 is required ただしPostgreSQL 9.6が必要
  • 82. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 Wrap up4 まとめ4 PGroonga makes PostgreSQL fast full text search platform for all languages! PGroongaでPostgreSQLが 全言語対応高速全文検索プラットフォームになる!
  • 83. PGroonga - Make PostgreSQL fast full text search platform for all languages! Powered by Rabbit 2.2.0 See also https://pgroonga.github.io/ Tutorial: /tutorial/ Install: /install/ Reference: /reference/ Includes replication doc and benchmark docs Community: /community/