File: tables.rst

package info (click to toggle)
groonga 9.0.0-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 101,496 kB
  • sloc: ansic: 608,707; ruby: 35,042; xml: 23,643; cpp: 10,319; sh: 7,453; yacc: 5,968; python: 3,033; makefile: 2,609; perl: 133
file content (216 lines) | stat: -rw-r--r-- 4,890 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
.. -*- rst -*-

.. highlightlang:: none

Tables
======

Summary
-------

Table in Groonga manages relation between ID and key. Groonga provides
four table types. They are ``TABLE_NO_KEY``, ``TABLE_HASH_KEY``,
``TABLE_PAT_KEY`` and ``TABLE_DAT_KEY``.

All tables except ``TABLE_NO_KEY`` provides both fast ID search by key
and fast key search by ID. ``TABLE_NO_KEY`` doesn't support
key. ``TABLE_NO_KEY`` only manages ID. So ``TABLE_NO_KEY`` doesn't
provides ID search and key search.

Characteristics
---------------

Here is a chracteristic table of all tables in Groonga. (``TABLE_``
prefix is omitted in the table.)

.. list-table:: Characteristics of all tables
   :header-rows: 1

   * - Item
     - ``NO_KEY``
     - ``HASH_KEY``
     - ``PAT_KEY``
     - ``DAT_KEY``
   * - Data structure
     - Array
     - Hash table
     - Patricia trie
     - Double array trie
   * - ID support
     - o
     - o
     - o
     - o
   * - Key support
     - x
     - o
     - o
     - o
   * - Value support
     - o
     - o
     - o
     - x
   * - Key -> ID speed

       * o: fast
       * x: slow
     - \-
     - oo
     - x
     - o
   * - Update speed

       * o: fast
       * x: slow
     - ooo
     - o
     - o
     - x
   * - Size

       * o: small
       * x: large
     - ooo
     - o
     - oo
     - x
   * - Key update
     - \-
     - x
     - x
     - o
   * - Common prefix search
     - \-
     - x
     - o
     - o
   * - Predictive search
     - \-
     - x
     - o
     - o
   * - Range search
     - \-
     - x
     - o
     - o
   * - The maximum one key size
     - \-
     - 4KiB
     - 4KiB
     - 4KiB
   * - The maximum total size of keys
     - \-
     - 4GiB or 1TiB (by specifying ``KEY_LARGE`` flag to
       :ref:`table-create-flags`)
     - 4GiB
     - 4GiB
   * - The maximum number of records
     - 1,073,741,815 (2 :sup:`30` - 9)
     - 536,870,912 (2 :sup:`29`)
     - 1,073,741,823 (2 :sup:`30` - 1)
     - 268,435,455 (2 :sup:`28` - 1)

.. _table-no-key:

``TABLE_NO_KEY``
^^^^^^^^^^^^^^^^

``TABLE_NO_KEY`` is very fast and very small but it doesn't support
key. ``TABLE_NO_KEY`` is a only table that doesn't support key.

You cannot use ``TABLE_NO_KEY`` for lexicon for fulltext search
because lexicon stores tokens as key. ``TABLE_NO_KEY`` is useful for
no key records such as log.

.. _table-hash-key:

``TABLE_HASH_KEY``
^^^^^^^^^^^^^^^^^^

``TABLE_HASH_KEY`` is fast but it doesn't support advanced search
functions such as common prefix search and predictive search.

``TABLE_HASH_KEY`` is useful for index for exact search such as tag
search.

.. _table-pat-key:

``TABLE_PAT_KEY``
^^^^^^^^^^^^^^^^^

``TABLE_PAT_KEY`` is small and supports advanced search functions.

``TABLE_PAT_KEY`` is useful for lexicon for fulltext search and
index for range search.

.. _table-dat-key:

``TABLE_DAT_KEY``
^^^^^^^^^^^^^^^^^

``TABLE_DAT_KEY`` is fast and supports key update but it is large. It
is not suitable for storing many records. ``TABLE_DAT_KEY`` is a only
table that supports key update.

``TABLE_DAT_KEY`` is used in Groonga database. Groonga database needs
to convert object name such as ``ShortText``, ``TokenBigram`` and
table names to object ID. And Groonga database needs to rename object
name. Those features are implemented by ``TABLE_DAT_KEY``. The number
of objects is small. So large data size demerit of ``TABLE_DAT_KEY``
can be ignored.

Record ID
---------

Record ID is assigned automatically. You cannot assign record ID.

Record ID of deleted record may be reused.

Valid record ID range is between 1 and 1073741823. (1 and 1073741823
are valid IDs.)

Persistent table and temporary table
------------------------------------

Table is persistent table or temporary table.

Persistent table
^^^^^^^^^^^^^^^^

Persistent table is named and registered to database. Records in
persistent table aren't deleted after closing table or
database.

Persistent table can be created by
:doc:`/reference/commands/table_create` command.

Temporary table
^^^^^^^^^^^^^^^

Temporary table is anonymous. Records in temporary table are deleted
after closing table. Temporary table is used to store search result,
sort result, group (drilldown) result and so on. ``TABLE_HASH_KEY`` is
used for search result and group result. ``TABLE_NO_KEY`` is used for
sort result.

Limitations
-----------

The max number of records is 268435455. You cannot add 268435456 or
more records in a table.

The max number of a key size is 4096byte. You cannot use 4097byte or
larger key. You can use column instead of key for 4097byte or larger
size data. ``Text`` and ``LargeText`` types supports 4097byte or
larger size data.

The max number of total key size is 4GiB. You need to split a table,
split a database (sharding) or reduce each key size to handle 4GiB or
more larger total key size.

See also
--------

* :doc:`/reference/commands/table_create`