rabbit-slide-kou-mysql-and-postgresql-and-japanese-full-text-search-2 2016.6.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rabbit +1 -0
- data/README.rd +46 -0
- data/Rakefile +17 -0
- data/config.yaml +27 -0
- data/images/groonga-logo.svg +118 -0
- data/images/mroonga-logo.svg +106 -0
- data/images/mroonga-mode.svg +3228 -0
- data/images/mroonga-transaction.svg +1062 -0
- data/images/pgroonga-logo.svg +84 -0
- data/mroonga-and-pgroonga.rab +700 -0
- data/pdf/mysql-and-postgresql-and-japanese-full-text-search-2-mroonga-and-pgroonga.pdf +0 -0
- metadata +84 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) -->
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg version="1.1"
|
5
|
+
id="svg4522" inkscape:version="0.48.1 r9760" sodipodi:docname="隴スー髫穂ク翫Λ郢ァュ郢晢ス・郢晢ス。郢晢スウ郢0" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
6
|
+
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="278px" height="73.012px"
|
7
|
+
viewBox="-24.833 0 278 73.012" enable-background="new -24.833 0 278 73.012" xml:space="preserve">
|
8
|
+
<sodipodi:namedview id="base" fit-margin-right="5" inkscape:window-x="1920" inkscape:window-height="442" inkscape:window-width="902" inkscape:pageopacity="0.0" inkscape:window-y="260" inkscape:current-layer="layer1" inkscape:document-units="px" fit-margin-bottom="4.9" inkscape:pageshadow="2" inkscape:window-maximized="0" bordercolor="#666666" showgrid="false" fit-margin-top="5" inkscape:cx="101.4407" borderopacity="1.0" pagecolor="#ffffff" fit-margin-left="5" inkscape:zoom="1.979899" inkscape:cy="55.868778">
|
9
|
+
</sodipodi:namedview>
|
10
|
+
<g>
|
11
|
+
<path fill="#030000" d="M78.954,25.236c-1.336-0.289-2.281-0.447-3.442-0.447c-2.847,0-5.33,0.831-7.391,2.468
|
12
|
+
c-0.091,0.06-0.192,0.14-0.303,0.245c-0.231,0.197-0.452,0.406-0.668,0.621c-1.479,1.314-2.761,1.952-2.761-1.234v-0.666
|
13
|
+
c0-0.404-0.327-0.732-0.731-0.732h-2.102c-0.197,0-0.388,0.08-0.524,0.223c-0.14,0.143-0.212,0.335-0.206,0.532
|
14
|
+
c0.104,3.333,0.215,6.778,0.215,9.621v18.75c0,0.403,0.328,0.731,0.731,0.731h2.21c0.403,0,0.731-0.328,0.731-0.731v-9.914
|
15
|
+
c0-1.37,0.107-3.806,0.309-4.813C66.592,32.091,70.005,28.3,75.458,28.3c0.979,0,1.881,0.165,2.874,0.363
|
16
|
+
c0.048,0.011,0.096,0.016,0.144,0.016c0.148,0,0.294-0.045,0.417-0.132c0.163-0.112,0.273-0.288,0.307-0.483l0.322-1.994
|
17
|
+
C79.584,25.685,79.335,25.318,78.954,25.236z"/>
|
18
|
+
<path fill="#030000" d="M168,26.828c-2.512-1.774-5.292-2.04-6.726-2.04c-2.91,0-5.648,0.912-7.822,2.495
|
19
|
+
c-0.005,0.004-0.01,0.005-0.015,0.009c-1.004,0.648-2.627,0.909-2.617-0.625v-0.021c0.002-0.106-0.003-0.198-0.014-0.276
|
20
|
+
l-0.008-0.183c-0.019-0.391-0.34-0.697-0.73-0.697h-2.103c-0.203,0-0.396,0.084-0.535,0.232c-0.138,0.147-0.209,0.346-0.194,0.549
|
21
|
+
c0.151,2.279,0.214,4.17,0.214,6.523v21.821c0,0.403,0.328,0.731,0.73,0.731h2.209c0.404,0,0.732-0.328,0.732-0.731V37.105
|
22
|
+
c0-0.813,0.253-1.762,0.49-2.377c0.004-0.008,0.006-0.019,0.01-0.026c1.043-3.042,4.224-6.12,8.417-6.476
|
23
|
+
c3.236,0.002,8.327,2.358,9.023,8.227c0.017,0.15,0.03,0.299,0.042,0.443c0.005,0.049,0.009,0.1,0.012,0.149
|
24
|
+
c0.005,0.07,0.009,0.14,0.014,0.209c0.009,0.19,0.015,0.384,0.015,0.582c0,0.335,0.007,0.638,0.018,0.911v15.869
|
25
|
+
c0,0.404,0.328,0.73,0.732,0.73h2.208c0.404,0,0.732-0.328,0.732-0.73V38.345C172.835,32.97,171.208,29.097,168,26.828z"/>
|
26
|
+
<path fill="#030000" d="M244.224,52.17c-0.133-0.112-0.301-0.174-0.473-0.174c-0.04,0-0.08,0.003-0.12,0.01
|
27
|
+
c-0.587,0.099-0.965,0.099-1.441,0.099c-1.147,0-2.178-0.336-2.178-4.387v-9.914c0-2.343-0.179-5.367-1.583-7.972
|
28
|
+
c-1.821-3.382-5.181-5.099-9.978-5.099c-2.476,0-6.217,0.517-9.99,2.975c-0.315,0.205-0.422,0.615-0.25,0.949l0.861,1.67
|
29
|
+
c0.098,0.189,0.271,0.326,0.478,0.375c0.059,0.014,0.116,0.021,0.173,0.021c0.151,0,0.3-0.047,0.425-0.136
|
30
|
+
c2.313-1.639,5.186-2.504,8.305-2.504c3.995,0,6.004,1.854,7,3.938l0,0c1.004,2.222-0.562,4.404-2.285,4.584
|
31
|
+
c-0.085,0.006-0.17,0.009-0.254,0.014c-0.014,0-0.028,0.001-0.042,0c-0.055-0.001-0.102,0.003-0.144,0.009
|
32
|
+
c-10.978,0.626-16.537,4.313-16.537,10.979c0,2.027,0.803,4.058,2.201,5.57c1.233,1.332,3.561,2.92,7.636,2.92
|
33
|
+
c3.471,0,6.271-1.111,8.324-2.472c0.062-0.03,0.131-0.075,0.212-0.142c0.022-0.016,0.042-0.03,0.063-0.047
|
34
|
+
c0.128-0.088,0.256-0.178,0.378-0.269c1.275-0.825,1.969-0.351,2.623,0.504c0.002,0.003,0.006,0.005,0.008,0.007
|
35
|
+
c0.84,1.141,2.161,1.719,3.962,1.719c0.847,0,1.592-0.094,2.345-0.295c0.319-0.084,0.543-0.375,0.543-0.707v-1.67
|
36
|
+
C244.484,52.515,244.388,52.31,244.224,52.17z M225.972,52.698c-3.042,0-6.11-1.724-6.11-5.572c0-4.862,5.936-6.58,12.167-7.043
|
37
|
+
c2.319-0.043,4.097,2.162,4.311,4.575v0.988c-0.062,0.647-0.246,1.289-0.568,1.889c-0.161,0.263-0.355,0.556-0.589,0.863
|
38
|
+
c-0.04,0.047-0.074,0.094-0.103,0.135C233.637,50.38,230.856,52.698,225.972,52.698z"/>
|
39
|
+
<path fill="#030000" d="M50.245,25.488h-2.047c-0.393,0-0.715,0.312-0.731,0.703c-0.064,1.619-0.892,1.836-2.704,0.767
|
40
|
+
c-0.01-0.006-0.018-0.015-0.025-0.019c-0.179-0.119-0.361-0.231-0.545-0.34c-0.012-0.006-0.021-0.012-0.032-0.02
|
41
|
+
c-0.088-0.059-0.169-0.104-0.245-0.141c-1.982-1.096-4.306-1.649-6.923-1.649c-3.739,0-7.429,1.548-10.122,4.25
|
42
|
+
c-2.083,2.087-4.564,5.826-4.564,11.784c0,3.818,1.348,7.412,3.792,10.121c2.595,2.875,6.234,4.459,10.249,4.459
|
43
|
+
c3.11,0,5.515-0.819,7.334-1.897c0.004-0.002,0.008-0.003,0.013-0.005c1.952-0.873,3.601-2.182,3.135,2.232
|
44
|
+
c-0.875,5.678-4.52,8.765-10.482,8.765c-4.175,0-7.31-1.403-9.204-2.583c-0.116-0.072-0.251-0.109-0.387-0.109
|
45
|
+
c-0.061,0-0.122,0.008-0.182,0.022c-0.193,0.049-0.358,0.176-0.456,0.351l-0.969,1.725c-0.189,0.336-0.086,0.761,0.236,0.972
|
46
|
+
c2.853,1.863,6.909,2.976,10.854,2.976c2.69,0,9.293-0.625,12.494-6.412c1.384-2.481,2.029-5.969,2.029-10.969V33.013
|
47
|
+
c0-2.474,0.07-4.679,0.214-6.738c0.015-0.201-0.057-0.401-0.194-0.549C50.642,25.573,50.448,25.488,50.245,25.488z M33.353,51.517
|
48
|
+
c-0.604-0.24-7.608-3.217-7.013-11.812c0.551-7.946,5.723-10.459,6.519-10.798c1.277-0.5,2.699-0.77,4.24-0.77
|
49
|
+
c1.664,0,3.112,0.327,4.354,0.873c6.846,3.871,7.696,16.453,0.885,21.467c-1.592,1-3.437,1.574-5.346,1.574
|
50
|
+
C35.65,52.052,34.439,51.857,33.353,51.517z"/>
|
51
|
+
<path fill="#030000" d="M208.092,25.488h-2.047c-0.393,0-0.716,0.312-0.731,0.703c-0.065,1.619-0.892,1.836-2.702,0.767
|
52
|
+
c-0.01-0.005-0.019-0.015-0.027-0.019c-0.178-0.119-0.362-0.231-0.546-0.34c-0.011-0.008-0.021-0.014-0.031-0.02
|
53
|
+
c-0.087-0.059-0.168-0.104-0.244-0.139c-1.981-1.098-4.307-1.651-6.924-1.651c-3.739,0-7.429,1.548-10.122,4.25
|
54
|
+
c-2.082,2.087-4.563,5.826-4.563,11.784c0,3.818,1.346,7.412,3.792,10.121c2.595,2.875,6.233,4.459,10.248,4.459
|
55
|
+
c3.11,0,5.514-0.819,7.335-1.897c0.004-0.002,0.007-0.003,0.012-0.005c1.954-0.874,3.603-2.184,3.135,2.232
|
56
|
+
c-0.875,5.679-4.519,8.765-10.481,8.765c-4.176,0-7.311-1.403-9.204-2.583c-0.118-0.072-0.251-0.109-0.388-0.109
|
57
|
+
c-0.06,0-0.122,0.008-0.182,0.022c-0.193,0.049-0.358,0.176-0.456,0.351l-0.97,1.725c-0.189,0.336-0.085,0.761,0.236,0.972
|
58
|
+
c2.854,1.863,6.91,2.976,10.854,2.976c2.688,0,9.293-0.625,12.493-6.412c1.385-2.481,2.031-5.969,2.031-10.969V33.013
|
59
|
+
c0-2.474,0.069-4.679,0.214-6.738c0.014-0.201-0.058-0.401-0.195-0.549C208.49,25.573,208.296,25.488,208.092,25.488z
|
60
|
+
M191.201,51.517c-0.605-0.24-7.609-3.217-7.014-11.812c0.552-7.94,5.717-10.455,6.518-10.798c1.278-0.5,2.701-0.77,4.242-0.77
|
61
|
+
c1.665,0,3.112,0.327,4.354,0.873c6.845,3.871,7.696,16.453,0.884,21.467c-1.592,1-3.436,1.574-5.345,1.574
|
62
|
+
C193.497,52.052,192.287,51.857,191.201,51.517z"/>
|
63
|
+
|
64
|
+
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="390.9009" y1="-115.3889" x2="390.9009" y2="-176.4133" gradientTransform="matrix(1 0 0 -1 -279.2305 -111.2632)">
|
65
|
+
<stop offset="0" style="stop-color:#5795C6"/>
|
66
|
+
<stop offset="1" style="stop-color:#0B3F63"/>
|
67
|
+
</linearGradient>
|
68
|
+
<path fill="url(#SVGID_1_)" d="M109.318,11.263c-2.338,2.336-4.109,5.342-5.032,8.654c-6.076-0.093-12.171,2.273-17.007,7.109
|
69
|
+
c-8.143,8.142-10.675,22.914,0.667,34.254c9.542,9.543,23.793,9.688,33.145,0.332c4.42-4.424,7.236-10.506,7.297-16.939
|
70
|
+
c3.14-0.835,6.124-2.507,8.669-5.049c6.956-6.959,9.086-18.919-0.311-28.318C128.914,3.476,117.121,3.459,109.318,11.263z
|
71
|
+
M134.939,31.685c-1.335,1.338-3.045,2.324-4.932,2.864c-3.027,0.867-4.656,0.777-5.697,2.515c-1.041,1.735-0.926,1.94-0.881,5.195
|
72
|
+
c0.057,3.688-1.332,7.512-4.813,10.994c-5.32,5.318-15.14,6.504-22.366-0.721c-5.693-5.694-8.365-15.278-0.778-22.865
|
73
|
+
c2.816-2.813,6.866-4.477,11.124-4.402c2.961,0.053,3.307,0.162,5.212-0.703c1.909-0.869,1.082-2.799,2.223-6.205
|
74
|
+
c0.556-1.66,1.544-3.295,3.091-4.844c4.127-4.127,11.721-5.072,17.285,0.49C138.941,18.538,140.863,25.763,134.939,31.685z"/>
|
75
|
+
<path fill="#040000" d="M0.388,24.795c-2.915,0-5.501,0.671-7.686,1.991c-0.526,0.318-1.027,0.676-1.5,1.068
|
76
|
+
c-1.114,1.113-2.128,2.432-2.128,0.062c0-0.817-0.077-1.722-0.077-1.722c-0.018-0.39-0.34-0.697-0.73-0.697h-2.156
|
77
|
+
c-0.201,0-0.393,0.081-0.531,0.227c-0.139,0.146-0.211,0.343-0.199,0.543c0.146,2.73,0.214,5.611,0.214,9.066v31.139
|
78
|
+
c0,0.404,0.327,0.731,0.731,0.731h2.209c0.404,0,0.732-0.327,0.732-0.731c0,0,0-9.742,0-11.516s0.603-2.513,2.086-1.485
|
79
|
+
c2.325,1.61,5.169,2.581,8.389,2.581c4.086,0,7.805-1.507,10.469-4.242c2.863-2.938,4.377-7.089,4.377-12.007
|
80
|
+
c0-4.005-1.338-7.725-3.766-10.471C8.196,26.365,4.589,24.795,0.388,24.795z M-0.259,52.756c-4.727,0-9.07-3.237-10.173-7.206
|
81
|
+
s-0.402-7.971,0.204-9.89c1.453-4.598,5.514-7.569,10.346-7.569c7.088,0,10.797,5.946,10.797,11.821
|
82
|
+
C10.915,47.835,6.634,52.756-0.259,52.756z"/>
|
83
|
+
</g>
|
84
|
+
</svg>
|
@@ -0,0 +1,700 @@
|
|
1
|
+
= Mroonga\n(('note:と'))\nPGroonga
|
2
|
+
|
3
|
+
: subtitle
|
4
|
+
初心者向け情報
|
5
|
+
: author
|
6
|
+
須藤功平
|
7
|
+
: institution
|
8
|
+
クリアコード
|
9
|
+
: content-source
|
10
|
+
MySQLとPostgreSQLと日本語全文検索
|
11
|
+
: date
|
12
|
+
2016-06-09
|
13
|
+
: allotted-time
|
14
|
+
20m
|
15
|
+
: theme
|
16
|
+
groonga
|
17
|
+
|
18
|
+
= Mroonga・PGroonga
|
19
|
+
|
20
|
+
* Mroonga(むるんが)
|
21
|
+
* (('wait'))MySQLに\n
|
22
|
+
高速日本語全文検索機能を追加する\n
|
23
|
+
プロダクト
|
24
|
+
* PGroonga(ぴーじーるんが)
|
25
|
+
* (('wait'))PostgreSQLに\n
|
26
|
+
高速日本語全文検索機能を追加する\n
|
27
|
+
プロダクト
|
28
|
+
|
29
|
+
= 使いどころ
|
30
|
+
|
31
|
+
* Mroonga
|
32
|
+
* (('wait'))速さが欲しい
|
33
|
+
* (('wait'))トランザクションはいらない
|
34
|
+
* PGroonga
|
35
|
+
* (('wait'))機能が欲しい
|
36
|
+
* (('wait'))トランザクションも欲しい
|
37
|
+
|
38
|
+
= 速い?
|
39
|
+
|
40
|
+
# image
|
41
|
+
# src = http://slide.rabbit-shocker.org/authors/kou/mysql-and-postgresql-and-japanese-full-text-search/mroonga-and-pgroonga.pdf
|
42
|
+
# page = 6
|
43
|
+
# relative_height = 80
|
44
|
+
|
45
|
+
(('tag:center'))
|
46
|
+
(('note:詳細は前回の資料を参照'))\n
|
47
|
+
(('note:http://slide.rabbit-shocker.org/authors/kou/mysql-and-postgresql-and-japanese-full-text-search/'))
|
48
|
+
|
49
|
+
= Mroongaのモード
|
50
|
+
|
51
|
+
* ストレージモード
|
52
|
+
* (('wait'))ストレージとインデックスに\n
|
53
|
+
Groongaを使う
|
54
|
+
* ラッパーモード
|
55
|
+
* (('wait'))ストレージは\n
|
56
|
+
既存ストレージエンジンをラップ
|
57
|
+
* (('wait'))(('note:全文検索・位置情報'))インデックスだけ\n
|
58
|
+
Groongaを使う
|
59
|
+
|
60
|
+
== スライドプロパティ
|
61
|
+
|
62
|
+
: groonga-product
|
63
|
+
|
64
|
+
mroonga
|
65
|
+
|
66
|
+
= Mroongaのモード
|
67
|
+
|
68
|
+
# image
|
69
|
+
# src = images/mroonga-mode.svg
|
70
|
+
# relative_height = 100
|
71
|
+
|
72
|
+
== スライドプロパティ
|
73
|
+
|
74
|
+
: groonga-product
|
75
|
+
|
76
|
+
mroonga
|
77
|
+
|
78
|
+
= ストレージモード
|
79
|
+
|
80
|
+
* (('wait'))全文検索が速い
|
81
|
+
* (('wait'))それ以外の条件も速い\n
|
82
|
+
(('note:数値の比較とか'))
|
83
|
+
* (('wait'))挿入も更新も削除も速い
|
84
|
+
* (('wait'))ソートも速い
|
85
|
+
* (('wait'))トランザクションはない
|
86
|
+
|
87
|
+
== スライドプロパティ
|
88
|
+
|
89
|
+
: groonga-product
|
90
|
+
|
91
|
+
mroonga
|
92
|
+
|
93
|
+
= ラッパーモード
|
94
|
+
|
95
|
+
* (('wait'))全文検索が速い
|
96
|
+
* (('wait'))全文検索以外はラップ対象の\n
|
97
|
+
ストレージエンジンに依存
|
98
|
+
* (('wait'))トランザクション
|
99
|
+
* ストレージのみ
|
100
|
+
* インデックスには効かない\n
|
101
|
+
(('note:ロールバックしたらインデックスの再構築が必要'))
|
102
|
+
|
103
|
+
== スライドプロパティ
|
104
|
+
|
105
|
+
: groonga-product
|
106
|
+
|
107
|
+
mroonga
|
108
|
+
|
109
|
+
= 使い分け
|
110
|
+
|
111
|
+
* (('wait'))できればストレージモード
|
112
|
+
* (('wait'))ムリならラッパーモード
|
113
|
+
|
114
|
+
== スライドプロパティ
|
115
|
+
|
116
|
+
: groonga-product
|
117
|
+
|
118
|
+
mroonga
|
119
|
+
|
120
|
+
= ストレージモードの条件
|
121
|
+
|
122
|
+
* (('wait'))(({NULL}))がないこと
|
123
|
+
* あるならテーブルをわけるか\n
|
124
|
+
ラッパーモード
|
125
|
+
* (('wait'))トランザクションを使わない
|
126
|
+
* 例:追記のみ(ログとか)
|
127
|
+
* 例:同時に更新されないようにする
|
128
|
+
* 例:スレーブにする(後述)
|
129
|
+
|
130
|
+
== スライドプロパティ
|
131
|
+
|
132
|
+
: groonga-product
|
133
|
+
|
134
|
+
mroonga
|
135
|
+
|
136
|
+
= オススメの使い方
|
137
|
+
|
138
|
+
* (('wait'))テーブル定義
|
139
|
+
* デフォルトで使う(('note:(いい感じになる)'))
|
140
|
+
* カスタマイズは慣れてからで十分
|
141
|
+
* (('wait'))検索
|
142
|
+
* (({IN BOOLEAN MODE}))を使う(('note:(いつもの検索)'))
|
143
|
+
* (({*D+}))プラグマを使う(('note:(デフォルトAND)'))
|
144
|
+
|
145
|
+
== スライドプロパティ
|
146
|
+
|
147
|
+
: groonga-product
|
148
|
+
|
149
|
+
mroonga
|
150
|
+
|
151
|
+
= テーブル定義
|
152
|
+
|
153
|
+
# coderay sql
|
154
|
+
|
155
|
+
CREATE TABLE items (
|
156
|
+
title TEXT,
|
157
|
+
FULLTEXT INDEX (title)
|
158
|
+
-- ↑COMMENTでカスタマイズしない
|
159
|
+
) ENGINE=Mroonga
|
160
|
+
DEFAULT CHARSET=utf8mb4;
|
161
|
+
|
162
|
+
== スライドプロパティ
|
163
|
+
|
164
|
+
: groonga-product
|
165
|
+
|
166
|
+
mroonga
|
167
|
+
|
168
|
+
= 検索
|
169
|
+
|
170
|
+
# coderay sql
|
171
|
+
|
172
|
+
SELECT * FROM items
|
173
|
+
WHERE
|
174
|
+
MATCH(title)
|
175
|
+
-- ↓*D+プラグマ
|
176
|
+
AGAINST('*D+ 激安 人気'
|
177
|
+
IN BOOLEAN MODE);
|
178
|
+
-- ↑IN BOOLEAN MODE
|
179
|
+
|
180
|
+
== スライドプロパティ
|
181
|
+
|
182
|
+
: groonga-product
|
183
|
+
|
184
|
+
mroonga
|
185
|
+
|
186
|
+
= トランザクション欲しい!
|
187
|
+
|
188
|
+
* (('wait'))レプリケーションで対応可能
|
189
|
+
* (('wait'))構成
|
190
|
+
* マスター:InnoDB
|
191
|
+
* スレーブ:Mroonga
|
192
|
+
* MySQLはマスターとスレーブで\n
|
193
|
+
違うストレージエンジンを使える!
|
194
|
+
|
195
|
+
== スライドプロパティ
|
196
|
+
|
197
|
+
: groonga-product
|
198
|
+
|
199
|
+
mroonga
|
200
|
+
|
201
|
+
= トランザクションと\nレプリケーション
|
202
|
+
|
203
|
+
# image
|
204
|
+
# src = images/mroonga-transaction.svg
|
205
|
+
# relative_width = 100
|
206
|
+
|
207
|
+
== スライドプロパティ
|
208
|
+
|
209
|
+
: groonga-product
|
210
|
+
|
211
|
+
mroonga
|
212
|
+
|
213
|
+
= レプリケーション手順1
|
214
|
+
|
215
|
+
マスターmy.cnf:
|
216
|
+
|
217
|
+
[mysqld]
|
218
|
+
log-bin=mysql-bin
|
219
|
+
server-id=1
|
220
|
+
|
221
|
+
(('tag:center'))
|
222
|
+
(('note:バイナリーログを有効にしてサーバーIDを指定'))
|
223
|
+
|
224
|
+
== スライドプロパティ
|
225
|
+
|
226
|
+
: groonga-product
|
227
|
+
|
228
|
+
mroonga
|
229
|
+
|
230
|
+
= レプリケーション手順2
|
231
|
+
|
232
|
+
スレーブmy.cnf:
|
233
|
+
|
234
|
+
[mysqld]
|
235
|
+
server-id=2
|
236
|
+
|
237
|
+
(('tag:center'))
|
238
|
+
(('note:サーバーIDを指定'))
|
239
|
+
|
240
|
+
== スライドプロパティ
|
241
|
+
|
242
|
+
: groonga-product
|
243
|
+
|
244
|
+
mroonga
|
245
|
+
|
246
|
+
= レプリケーション手順3
|
247
|
+
|
248
|
+
マスター:
|
249
|
+
|
250
|
+
# coderay sql
|
251
|
+
CREATE USER 'repl'@'%' IDENTIFIED BY '1qazXSW@';
|
252
|
+
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
|
253
|
+
|
254
|
+
(('tag:center'))
|
255
|
+
(('note:レプリケーション用ユーザーを作成'))
|
256
|
+
|
257
|
+
== スライドプロパティ
|
258
|
+
|
259
|
+
: groonga-product
|
260
|
+
|
261
|
+
mroonga
|
262
|
+
|
263
|
+
= レプリケーション手順4
|
264
|
+
|
265
|
+
マスター:
|
266
|
+
|
267
|
+
# coderay sql
|
268
|
+
SHOW MASTER STATUS\G
|
269
|
+
-- File: mysql-bin.000001
|
270
|
+
-- Position: 855
|
271
|
+
-- Binlog_Do_DB:
|
272
|
+
-- Binlog_Ignore_DB:
|
273
|
+
-- Executed_Gtid_Set:
|
274
|
+
|
275
|
+
(('tag:center'))
|
276
|
+
(('note:バイナリーログの情報を確認'))
|
277
|
+
|
278
|
+
== スライドプロパティ
|
279
|
+
|
280
|
+
: groonga-product
|
281
|
+
|
282
|
+
mroonga
|
283
|
+
|
284
|
+
= レプリケーション手順5
|
285
|
+
|
286
|
+
スレーブ:
|
287
|
+
|
288
|
+
# coderay sql
|
289
|
+
CHANGE MASTER TO
|
290
|
+
MASTER_HOST='192.168.0.9',
|
291
|
+
MASTER_LOG_FILE='mysql-bin.000001',
|
292
|
+
MASTER_LOG_POS=855;
|
293
|
+
START SLAVE USER='repl'
|
294
|
+
PASSWORD='1qazXSW@';
|
295
|
+
|
296
|
+
(('tag:center'))
|
297
|
+
(('note:レプリケーション開始'))
|
298
|
+
|
299
|
+
== スライドプロパティ
|
300
|
+
|
301
|
+
: groonga-product
|
302
|
+
|
303
|
+
mroonga
|
304
|
+
|
305
|
+
= レプリケーション手順6
|
306
|
+
|
307
|
+
マスター:
|
308
|
+
|
309
|
+
# coderay sql
|
310
|
+
CREATE TABLE items (
|
311
|
+
title text
|
312
|
+
) DEFAULT CHARSET=utf8mb4;
|
313
|
+
|
314
|
+
(('tag:center'))
|
315
|
+
(('note:マスターでテーブル作成'))
|
316
|
+
|
317
|
+
== スライドプロパティ
|
318
|
+
|
319
|
+
: groonga-product
|
320
|
+
|
321
|
+
mroonga
|
322
|
+
|
323
|
+
= レプリケーション手順7
|
324
|
+
|
325
|
+
スレーブ:
|
326
|
+
|
327
|
+
# coderay sql
|
328
|
+
ALTER TABLE items
|
329
|
+
ENGINE=Mroonga,
|
330
|
+
ADD FULLTEXT INDEX (title);
|
331
|
+
|
332
|
+
(('tag:center'))
|
333
|
+
(('note:スレーブだけMroongaに変更'))
|
334
|
+
|
335
|
+
== スライドプロパティ
|
336
|
+
|
337
|
+
: groonga-product
|
338
|
+
|
339
|
+
mroonga
|
340
|
+
|
341
|
+
= レプリケーション手順8
|
342
|
+
|
343
|
+
マスター:
|
344
|
+
|
345
|
+
# coderay sql
|
346
|
+
INSERT INTO items
|
347
|
+
VALUES ('データベース管理システム');
|
348
|
+
|
349
|
+
(('tag:center'))
|
350
|
+
(('note:マスターでデータ登録'))
|
351
|
+
|
352
|
+
== スライドプロパティ
|
353
|
+
|
354
|
+
: groonga-product
|
355
|
+
|
356
|
+
mroonga
|
357
|
+
|
358
|
+
= レプリケーション手順9
|
359
|
+
|
360
|
+
スレーブ:
|
361
|
+
|
362
|
+
# coderay sql
|
363
|
+
SELECT * FROM items
|
364
|
+
WHERE MATCH(title)
|
365
|
+
AGAINST('*D+ データ 管理'
|
366
|
+
IN BOOLEAN MODE);
|
367
|
+
-- +--------------------------------------+
|
368
|
+
-- | title |
|
369
|
+
-- +--------------------------------------+
|
370
|
+
-- | データベース管理システム |
|
371
|
+
-- +--------------------------------------+
|
372
|
+
|
373
|
+
(('tag:center'))
|
374
|
+
(('note:スレーブで全文検索'))
|
375
|
+
|
376
|
+
== スライドプロパティ
|
377
|
+
|
378
|
+
: groonga-product
|
379
|
+
|
380
|
+
mroonga
|
381
|
+
|
382
|
+
= まとめ
|
383
|
+
|
384
|
+
* (('wait'))できればストレージモード
|
385
|
+
* (('wait'))テーブル定義:デフォルトでOK
|
386
|
+
* (('wait'))検索:(({IN BOOLEAN MODE}))と(({*D+}))
|
387
|
+
* (('wait'))トランザクション:スレーブ
|
388
|
+
|
389
|
+
== スライドプロパティ
|
390
|
+
|
391
|
+
: groonga-product
|
392
|
+
|
393
|
+
mroonga
|
394
|
+
|
395
|
+
= PGroongaのいいところ
|
396
|
+
|
397
|
+
* (('wait'))検索条件を柔軟に指定可能
|
398
|
+
* MySQL:拡張は(({AGAINST()}))内で頑張る
|
399
|
+
* PostgreSQL:演算子を追加可能
|
400
|
+
* (('wait'))トランザクション対応
|
401
|
+
* ロールバックも効く
|
402
|
+
|
403
|
+
== スライドプロパティ
|
404
|
+
|
405
|
+
: groonga-product
|
406
|
+
|
407
|
+
pgroonga
|
408
|
+
|
409
|
+
= オススメの使い方
|
410
|
+
|
411
|
+
* (('wait'))テーブル定義
|
412
|
+
* 主キーを指定する
|
413
|
+
* (('wait'))インデックス定義
|
414
|
+
* デフォルトで使う(('note:(いい感じになる)'))
|
415
|
+
* (('wait'))検索
|
416
|
+
* (({search_path}))設定→(({@@}))演算子を使う
|
417
|
+
|
418
|
+
== スライドプロパティ
|
419
|
+
|
420
|
+
: groonga-product
|
421
|
+
|
422
|
+
pgroonga
|
423
|
+
|
424
|
+
= テーブル定義
|
425
|
+
|
426
|
+
# coderay sql
|
427
|
+
|
428
|
+
CREATE TABLE items (
|
429
|
+
id integer PRIMARY KEY,
|
430
|
+
title text
|
431
|
+
);
|
432
|
+
|
433
|
+
(('tag:center'))
|
434
|
+
(('note:スコアー取得時に必要なので主キーを指定'))
|
435
|
+
|
436
|
+
== スライドプロパティ
|
437
|
+
|
438
|
+
: groonga-product
|
439
|
+
|
440
|
+
pgroonga
|
441
|
+
|
442
|
+
= インデックス定義
|
443
|
+
|
444
|
+
# coderay sql
|
445
|
+
|
446
|
+
CREATE INDEX pgroonga_items_index
|
447
|
+
ON items
|
448
|
+
USING pgroonga (id, title);
|
449
|
+
|
450
|
+
(('tag:center'))
|
451
|
+
(('note:主キーをインデックス対象にする'))
|
452
|
+
|
453
|
+
== スライドプロパティ
|
454
|
+
|
455
|
+
: groonga-product
|
456
|
+
|
457
|
+
pgroonga
|
458
|
+
|
459
|
+
= (({search_path}))を設定
|
460
|
+
|
461
|
+
# coderay sql
|
462
|
+
|
463
|
+
-- 現在のセッションのみ有効
|
464
|
+
SET search_path TO "$user",public,pgroonga,pg_catalog;
|
465
|
+
-- user1ユーザーのみ有効
|
466
|
+
ALTER ROLE user1
|
467
|
+
SET search_path TO "$user",public,pgroonga,pg_catalog;
|
468
|
+
-- db1データベースでは永続的に有効
|
469
|
+
ALTER DATABASE db1
|
470
|
+
SET search_path TO "$user",public,pgroonga,pg_catalog;
|
471
|
+
|
472
|
+
(('tag:center'))
|
473
|
+
(('note:pg_catalogの前にpgroongaを入れる'))
|
474
|
+
|
475
|
+
== スライドプロパティ
|
476
|
+
|
477
|
+
: groonga-product
|
478
|
+
|
479
|
+
pgroonga
|
480
|
+
|
481
|
+
= なぜ設定する必要があるか
|
482
|
+
|
483
|
+
(('tag:center'))
|
484
|
+
PostgreSQLに(({@@}))があるから
|
485
|
+
|
486
|
+
* (('wait'))組み込みの(({@@}))より\n
|
487
|
+
PGroongaの(({@@}))を優先したい
|
488
|
+
* (('wait'))優先しないと\n
|
489
|
+
インデックススキャンと\n
|
490
|
+
シーケンシャルスキャンで\n
|
491
|
+
結果が異なる
|
492
|
+
|
493
|
+
== スライドプロパティ
|
494
|
+
|
495
|
+
: groonga-product
|
496
|
+
|
497
|
+
pgroonga
|
498
|
+
|
499
|
+
= (({@@}))演算子で検索
|
500
|
+
|
501
|
+
# coderay sql
|
502
|
+
|
503
|
+
SELECT *,
|
504
|
+
pgroonga.score(items) AS score
|
505
|
+
FROM items
|
506
|
+
WHERE title @@ '激安 人気'
|
507
|
+
ORDER BY score DESC;
|
508
|
+
|
509
|
+
== スライドプロパティ
|
510
|
+
|
511
|
+
: groonga-product
|
512
|
+
|
513
|
+
pgroonga
|
514
|
+
|
515
|
+
= 独自演算子がうれしい例
|
516
|
+
|
517
|
+
入力補完\n
|
518
|
+
(('note:https://github.com/pgroonga/pgroonga/tree/master/examples/completion'))
|
519
|
+
|
520
|
+
== スライドプロパティ
|
521
|
+
|
522
|
+
: groonga-product
|
523
|
+
|
524
|
+
pgroonga
|
525
|
+
|
526
|
+
= テーブル作成
|
527
|
+
|
528
|
+
# coderay sql
|
529
|
+
|
530
|
+
CREATE TABLE dictionary (
|
531
|
+
term text,
|
532
|
+
readings text[], -- 配列
|
533
|
+
english text
|
534
|
+
);
|
535
|
+
|
536
|
+
== スライドプロパティ
|
537
|
+
|
538
|
+
: groonga-product
|
539
|
+
|
540
|
+
pgroonga
|
541
|
+
|
542
|
+
= データ
|
543
|
+
|
544
|
+
# coderay sql
|
545
|
+
|
546
|
+
INSERT INTO dictionary VALUES
|
547
|
+
('・',
|
548
|
+
ARRAY['ナカグロ', 'ナカポチ'],
|
549
|
+
'(n) middle dot ...'),
|
550
|
+
-- (...),
|
551
|
+
('踵',
|
552
|
+
ARRAY['カカト', 'キビス', 'クビス'],
|
553
|
+
'(n) (uk) heel ...');
|
554
|
+
|
555
|
+
== スライドプロパティ
|
556
|
+
|
557
|
+
: groonga-product
|
558
|
+
|
559
|
+
pgroonga
|
560
|
+
|
561
|
+
= インデックス定義
|
562
|
+
|
563
|
+
# coderay sql
|
564
|
+
|
565
|
+
CREATE INDEX pgroonga_index
|
566
|
+
ON dictionary
|
567
|
+
USING pgroonga (
|
568
|
+
-- ↓前方一致・前方一致RK検索用
|
569
|
+
term pgroonga.text_term_search_ops_v2,
|
570
|
+
-- ↓配列に対する前方一致・前方一致RK検索用
|
571
|
+
readings pgroonga.text_array_term_search_ops_v2);
|
572
|
+
|
573
|
+
== スライドプロパティ
|
574
|
+
|
575
|
+
: groonga-product
|
576
|
+
|
577
|
+
pgroonga
|
578
|
+
|
579
|
+
= 検索:独自演算子+OR
|
580
|
+
|
581
|
+
# coderay sql
|
582
|
+
|
583
|
+
SELECT term, readings, english
|
584
|
+
FROM dictionary
|
585
|
+
WHERE term &^ 'nak' OR
|
586
|
+
-- ↑前方一致検索
|
587
|
+
readings &^~> 'nak'
|
588
|
+
-- ↑前方一致RK検索
|
589
|
+
ORDER BY term LIMIT 10;
|
590
|
+
|
591
|
+
== スライドプロパティ
|
592
|
+
|
593
|
+
: groonga-product
|
594
|
+
|
595
|
+
pgroonga
|
596
|
+
|
597
|
+
= 結果例:nak
|
598
|
+
|
599
|
+
(('tag:center'))
|
600
|
+
前方一致RK検索でヒット
|
601
|
+
|
602
|
+
# _
|
603
|
+
term | readings | english
|
604
|
+
--------------+----------------------+-------------------
|
605
|
+
・ | {ナカグロ,ナカポチ} | (n) middle dot ...
|
606
|
+
NaK | {ナック} | (n) NaK (sodiu...
|
607
|
+
なくても良い | {ナクテモヨイ | (exp) (1) (uk) ...
|
608
|
+
... | ... | ...
|
609
|
+
(10 rows)
|
610
|
+
|
611
|
+
== スライドプロパティ
|
612
|
+
|
613
|
+
: groonga-product
|
614
|
+
|
615
|
+
pgroonga
|
616
|
+
|
617
|
+
= 結果例:なか
|
618
|
+
|
619
|
+
(('tag:center'))
|
620
|
+
前方一致RK検索でヒット
|
621
|
+
|
622
|
+
# _
|
623
|
+
term | readings | english
|
624
|
+
--------------+----------------------+-------------------
|
625
|
+
・ | {ナカグロ,ナカポチ} | (n) middle dot ...
|
626
|
+
泣かされる | {ナカサレル} | (v1,vi) (1) to ...
|
627
|
+
泣かせる | {ナカセル} | (v1,vt) (1) to ...
|
628
|
+
... | ... | ...
|
629
|
+
(10 rows)
|
630
|
+
|
631
|
+
== スライドプロパティ
|
632
|
+
|
633
|
+
: groonga-product
|
634
|
+
|
635
|
+
pgroonga
|
636
|
+
|
637
|
+
= 結果例:中
|
638
|
+
|
639
|
+
(('tag:center'))
|
640
|
+
前方一致RK検索でヒット
|
641
|
+
|
642
|
+
# _
|
643
|
+
term | readings | english
|
644
|
+
--------------+----------------------+-------------------
|
645
|
+
中 | {ウチ,ジュウ,チュウ} | (n,adj-no) (1) ...
|
646
|
+
中々 | {ナカナカ} | (adv,adj-na) ..
|
647
|
+
中2 | {チュウニ} | (n) second-year
|
648
|
+
... | ... | ...
|
649
|
+
(10 rows)
|
650
|
+
|
651
|
+
== スライドプロパティ
|
652
|
+
|
653
|
+
: groonga-product
|
654
|
+
|
655
|
+
pgroonga
|
656
|
+
|
657
|
+
= レプリケーション
|
658
|
+
|
659
|
+
* (('wait'))PostgreSQL標準機能:×
|
660
|
+
* プラグインはWALを使えない
|
661
|
+
* (('wait'))pglogical:○\n
|
662
|
+
(('note:詳細:http://www.clear-code.com/blog/2016/3/22.html'))
|
663
|
+
* (('wait'))PostgreSQL 9.6:たぶん○
|
664
|
+
* プラグインでもWALを使える
|
665
|
+
* 正式リリースまでに対応したい
|
666
|
+
|
667
|
+
= まとめ
|
668
|
+
|
669
|
+
* (('wait'))トランザクション対応
|
670
|
+
* (('wait'))テーブル定義:主キーを指定
|
671
|
+
* (('wait'))インデックス定義:デフォルト
|
672
|
+
* (('wait'))検索:(({search_path}))と(({@@}))
|
673
|
+
* (('wait'))レプリケーション:pglogical
|
674
|
+
|
675
|
+
== スライドプロパティ
|
676
|
+
|
677
|
+
: groonga-product
|
678
|
+
|
679
|
+
pgroonga
|
680
|
+
|
681
|
+
= 相談場所
|
682
|
+
|
683
|
+
* メーリングリスト
|
684
|
+
* groonga-dev
|
685
|
+
* チャット
|
686
|
+
* https://gitter.im/groonga/ja
|
687
|
+
* Twitter:@groonga
|
688
|
+
* 勉強会
|
689
|
+
|
690
|
+
= 勉強会
|
691
|
+
|
692
|
+
(('tag:center'))
|
693
|
+
(('tag:margin-bottom * 3'))
|
694
|
+
「Groongaで学ぶ全文検索」
|
695
|
+
|
696
|
+
* (('wait'))全文検索について学ぶ会
|
697
|
+
* (('wait'))内容は参加者が知りたいこと
|
698
|
+
* (('wait'))ほぼ隔週金曜夜開催
|
699
|
+
* 次回は6月17日\n
|
700
|
+
(('note:https://groonga.doorkeeper.jp/events/45556'))
|