Debian Codegraph @

doc/source/reference/tables.rst

raw
1 .. -*- rst -*-
2
3 Tables
4 ======
5
6 Summary
7 -------
8
9 Table in Groonga manages relation between ID and key. Groonga provides
10 four table types. They are ``TABLE_NO_KEY``, ``TABLE_HASH_KEY``,
11 ``TABLE_PAT_KEY`` and ``TABLE_DAT_KEY``.
12
13 All tables except ``TABLE_NO_KEY`` provides both fast ID search by key
14 and fast key search by ID. ``TABLE_NO_KEY`` doesn't support
15 key. ``TABLE_NO_KEY`` only manages ID. So ``TABLE_NO_KEY`` doesn't
16 provides ID search and key search.
17
18 Characteristics
19 ---------------
20
21 Here is a characteristic table of all tables in Groonga. (``TABLE_``
22 prefix is omitted in the table.)
23
24 .. list-table:: Characteristics of all tables
25 :header-rows: 1
26
27 * - Item
28 - ``NO_KEY``
29 - ``HASH_KEY``
30 - ``PAT_KEY``
31 - ``DAT_KEY``
32 * - Data structure
33 - Array
34 - Hash table
35 - Patricia trie
36 - Double array trie
37 * - ID support
38 - o
39 - o
40 - o
41 - o
42 * - Key support
43 - x
44 - o
45 - o
46 - o
47 * - Value support
48 - o
49 - o
50 - o
51 - x
52 * - Key -> ID speed
53
54 * o: fast
55 * x: slow
56 - \-
57 - oo
58 - x
59 - o
60 * - Update speed
61
62 * o: fast
63 * x: slow
64 - ooo
65 - o
66 - o
67 - x
68 * - Size
69
70 * o: small
71 * x: large
72 - ooo
73 - o
74 - oo
75 - x
76 * - Key update
77 - \-
78 - x
79 - x
80 - o
81 * - Common prefix search
82 - \-
83 - x
84 - o
85 - o
86 * - Predictive search
87 - \-
88 - x
89 - o
90 - o
91 * - Range search
92 - \-
93 - x
94 - o
95 - o
96 * - The maximum one key size
97 - \-
98 - 4KiB
99 - 4KiB
100 - 4KiB
101 * - The maximum total size of keys
102 - \-
103 - 4GiB or 1TiB (by specifying ``KEY_LARGE`` flag to
104 :ref:`table-create-flags`)
105 - 4GiB or 1TiB (by specifying ``KEY_LARGE`` flag to
106 :ref:`table-create-flags`)
107 - 4GiB
108 * - The maximum number of records
109 - 1,073,741,815 (2 :sup:`30` - 9)
110 - 536,870,912 (2 :sup:`29`)
111 - 1,073,741,823 (2 :sup:`30` - 1)
112 - 268,435,455 (2 :sup:`28` - 1)
113
114 .. _table-no-key:
115
116 ``TABLE_NO_KEY``
117 ^^^^^^^^^^^^^^^^
118
119 ``TABLE_NO_KEY`` is very fast and very small but it doesn't support
120 key. ``TABLE_NO_KEY`` is a only table that doesn't support key.
121
122 You cannot use ``TABLE_NO_KEY`` for lexicon for fulltext search
123 because lexicon stores tokens as key. ``TABLE_NO_KEY`` is useful for
124 no key records such as log.
125
126 .. _table-hash-key:
127
128 ``TABLE_HASH_KEY``
129 ^^^^^^^^^^^^^^^^^^
130
131 ``TABLE_HASH_KEY`` is fast but it doesn't support advanced search
132 functions such as common prefix search and predictive search.
133
134 ``TABLE_HASH_KEY`` is useful for index for exact search such as tag
135 search.
136
137 .. _table-pat-key:
138
139 ``TABLE_PAT_KEY``
140 ^^^^^^^^^^^^^^^^^
141
142 ``TABLE_PAT_KEY`` is small and supports advanced search functions.
143
144 ``TABLE_PAT_KEY`` is useful for lexicon for fulltext search and
145 index for range search.
146
147 .. _table-dat-key:
148
149 ``TABLE_DAT_KEY``
150 ^^^^^^^^^^^^^^^^^
151
152 ``TABLE_DAT_KEY`` is fast and supports key update but it is large. It
153 is not suitable for storing many records. ``TABLE_DAT_KEY`` is a only
154 table that supports key update.
155
156 ``TABLE_DAT_KEY`` is used in Groonga database. Groonga database needs
157 to convert object name such as ``ShortText``, ``TokenBigram`` and
158 table names to object ID. And Groonga database needs to rename object
159 name. Those features are implemented by ``TABLE_DAT_KEY``. The number
160 of objects is small. So large data size demerit of ``TABLE_DAT_KEY``
161 can be ignored.
162
163 Record ID
164 ---------
165
166 Record ID is assigned automatically. You cannot assign record ID.
167
168 Record ID of deleted record may be reused.
169
170 Valid record ID range is between 1 and 1073741823. (1 and 1073741823
171 are valid IDs.)
172
173 Persistent table and temporary table
174 ------------------------------------
175
176 Table is persistent table or temporary table.
177
178 Persistent table
179 ^^^^^^^^^^^^^^^^
180
181 Persistent table is named and registered to database. Records in
182 persistent table aren't deleted after closing table or
183 database.
184
185 Persistent table can be created by
186 :doc:`/reference/commands/table_create` command.
187
188 Temporary table
189 ^^^^^^^^^^^^^^^
190
191 Temporary table is anonymous. Records in temporary table are deleted
192 after closing table. Temporary table is used to store search result,
193 sort result, group (drilldown) result and so on. ``TABLE_HASH_KEY`` is
194 used for search result and group result. ``TABLE_NO_KEY`` is used for
195 sort result.
196
197 Limitations
198 -----------
199
200 The max number of records is 268435455. You cannot add 268435456 or
201 more records in a table.
202
203 The max number of a key size is 4096byte. You cannot use 4097byte or
204 larger key. You can use column instead of key for 4097byte or larger
205 size data. ``Text`` and ``LargeText`` types supports 4097byte or
206 larger size data.
207
208 The max number of total key size is 4GiB. You need to split a table,
209 split a database (sharding) or reduce each key size to handle 4GiB or
210 more larger total key size.
211
212 See also
213 --------
214
215 * :doc:`/reference/commands/table_create`