~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to doc/src/sgml/html/gin-tips.html

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
2
<HTML
 
3
><HEAD
 
4
><TITLE
 
5
>GIN Tips and Tricks</TITLE
 
6
><META
 
7
NAME="GENERATOR"
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
 
9
REV="MADE"
 
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
 
11
REL="HOME"
 
12
TITLE="PostgreSQL 9.1beta1 Documentation"
 
13
HREF="index.html"><LINK
 
14
REL="UP"
 
15
TITLE="GIN Indexes"
 
16
HREF="gin.html"><LINK
 
17
REL="PREVIOUS"
 
18
TITLE="Implementation"
 
19
HREF="gin-implementation.html"><LINK
 
20
REL="NEXT"
 
21
TITLE="Limitations"
 
22
HREF="gin-limit.html"><LINK
 
23
REL="STYLESHEET"
 
24
TYPE="text/css"
 
25
HREF="stylesheet.css"><META
 
26
HTTP-EQUIV="Content-Type"
 
27
CONTENT="text/html; charset=ISO-8859-1"><META
 
28
NAME="creation"
 
29
CONTENT="2011-04-27T21:20:33"></HEAD
 
30
><BODY
 
31
CLASS="SECT1"
 
32
><DIV
 
33
CLASS="NAVHEADER"
 
34
><TABLE
 
35
SUMMARY="Header navigation table"
 
36
WIDTH="100%"
 
37
BORDER="0"
 
38
CELLPADDING="0"
 
39
CELLSPACING="0"
 
40
><TR
 
41
><TH
 
42
COLSPAN="5"
 
43
ALIGN="center"
 
44
VALIGN="bottom"
 
45
><A
 
46
HREF="index.html"
 
47
>PostgreSQL 9.1beta1 Documentation</A
 
48
></TH
 
49
></TR
 
50
><TR
 
51
><TD
 
52
WIDTH="10%"
 
53
ALIGN="left"
 
54
VALIGN="top"
 
55
><A
 
56
TITLE="Implementation"
 
57
HREF="gin-implementation.html"
 
58
ACCESSKEY="P"
 
59
>Prev</A
 
60
></TD
 
61
><TD
 
62
WIDTH="10%"
 
63
ALIGN="left"
 
64
VALIGN="top"
 
65
><A
 
66
TITLE="GIN Indexes"
 
67
HREF="gin.html"
 
68
>Fast Backward</A
 
69
></TD
 
70
><TD
 
71
WIDTH="60%"
 
72
ALIGN="center"
 
73
VALIGN="bottom"
 
74
>Chapter 54. GIN Indexes</TD
 
75
><TD
 
76
WIDTH="10%"
 
77
ALIGN="right"
 
78
VALIGN="top"
 
79
><A
 
80
TITLE="GIN Indexes"
 
81
HREF="gin.html"
 
82
>Fast Forward</A
 
83
></TD
 
84
><TD
 
85
WIDTH="10%"
 
86
ALIGN="right"
 
87
VALIGN="top"
 
88
><A
 
89
TITLE="Limitations"
 
90
HREF="gin-limit.html"
 
91
ACCESSKEY="N"
 
92
>Next</A
 
93
></TD
 
94
></TR
 
95
></TABLE
 
96
><HR
 
97
ALIGN="LEFT"
 
98
WIDTH="100%"></DIV
 
99
><DIV
 
100
CLASS="SECT1"
 
101
><H1
 
102
CLASS="SECT1"
 
103
><A
 
104
NAME="GIN-TIPS"
 
105
>54.4. GIN Tips and Tricks</A
 
106
></H1
 
107
><P
 
108
></P
 
109
><DIV
 
110
CLASS="VARIABLELIST"
 
111
><DL
 
112
><DT
 
113
>Create vs. insert</DT
 
114
><DD
 
115
><P
 
116
>     Insertion into a <ACRONYM
 
117
CLASS="ACRONYM"
 
118
>GIN</ACRONYM
 
119
> index can be slow
 
120
     due to the likelihood of many keys being inserted for each item.
 
121
     So, for bulk insertions into a table it is advisable to drop the GIN
 
122
     index and recreate it after finishing bulk insertion.
 
123
    </P
 
124
><P
 
125
>     As of <SPAN
 
126
CLASS="PRODUCTNAME"
 
127
>PostgreSQL</SPAN
 
128
> 8.4, this advice is less
 
129
     necessary since delayed indexing is used (see <A
 
130
HREF="gin-implementation.html#GIN-FAST-UPDATE"
 
131
>Section 54.3.1</A
 
132
> for details).  But for very large updates
 
133
     it may still be best to drop and recreate the index.
 
134
    </P
 
135
></DD
 
136
><DT
 
137
><A
 
138
HREF="runtime-config-resource.html#GUC-MAINTENANCE-WORK-MEM"
 
139
>maintenance_work_mem</A
 
140
></DT
 
141
><DD
 
142
><P
 
143
>     Build time for a <ACRONYM
 
144
CLASS="ACRONYM"
 
145
>GIN</ACRONYM
 
146
> index is very sensitive to
 
147
     the <TT
 
148
CLASS="VARNAME"
 
149
>maintenance_work_mem</TT
 
150
> setting; it doesn't pay to
 
151
     skimp on work memory during index creation.
 
152
    </P
 
153
></DD
 
154
><DT
 
155
><A
 
156
HREF="runtime-config-resource.html#GUC-WORK-MEM"
 
157
>work_mem</A
 
158
></DT
 
159
><DD
 
160
><P
 
161
>     During a series of insertions into an existing <ACRONYM
 
162
CLASS="ACRONYM"
 
163
>GIN</ACRONYM
 
164
>
 
165
     index that has <TT
 
166
CLASS="LITERAL"
 
167
>FASTUPDATE</TT
 
168
> enabled, the system will clean up
 
169
     the pending-entry list whenever the list grows larger than
 
170
     <TT
 
171
CLASS="VARNAME"
 
172
>work_mem</TT
 
173
>.  To avoid fluctuations in observed response time,
 
174
     it's desirable to have pending-list cleanup occur in the background
 
175
     (i.e., via autovacuum).  Foreground cleanup operations can be avoided by
 
176
     increasing <TT
 
177
CLASS="VARNAME"
 
178
>work_mem</TT
 
179
> or making autovacuum more aggressive.
 
180
     However, enlarging <TT
 
181
CLASS="VARNAME"
 
182
>work_mem</TT
 
183
> means that if a foreground
 
184
     cleanup does occur, it will take even longer.
 
185
    </P
 
186
></DD
 
187
><DT
 
188
><A
 
189
HREF="runtime-config-client.html#GUC-GIN-FUZZY-SEARCH-LIMIT"
 
190
>gin_fuzzy_search_limit</A
 
191
></DT
 
192
><DD
 
193
><P
 
194
>     The primary goal of developing <ACRONYM
 
195
CLASS="ACRONYM"
 
196
>GIN</ACRONYM
 
197
> indexes was
 
198
     to create support for highly scalable full-text search in
 
199
     <SPAN
 
200
CLASS="PRODUCTNAME"
 
201
>PostgreSQL</SPAN
 
202
>, and there are often situations when
 
203
     a full-text search returns a very large set of results.  Moreover, this
 
204
     often happens when the query contains very frequent words, so that the
 
205
     large result set is not even useful.  Since reading many
 
206
     tuples from the disk and sorting them could take a lot of time, this is
 
207
     unacceptable for production.  (Note that the index search itself is very
 
208
     fast.)
 
209
    </P
 
210
><P
 
211
>     To facilitate controlled execution of such queries,
 
212
     <ACRONYM
 
213
CLASS="ACRONYM"
 
214
>GIN</ACRONYM
 
215
> has a configurable soft upper limit on the
 
216
     number of rows returned: the
 
217
     <TT
 
218
CLASS="VARNAME"
 
219
>gin_fuzzy_search_limit</TT
 
220
> configuration parameter.
 
221
     It is set to 0 (meaning no limit) by default.
 
222
     If a non-zero limit is set, then the returned set is a subset of
 
223
     the whole result set, chosen at random.
 
224
    </P
 
225
><P
 
226
>     <SPAN
 
227
CLASS="QUOTE"
 
228
>"Soft"</SPAN
 
229
> means that the actual number of returned results
 
230
     could differ somewhat from the specified limit, depending on the query
 
231
     and the quality of the system's random number generator.
 
232
    </P
 
233
><P
 
234
>     From experience, values in the thousands (e.g., 5000 &mdash; 20000)
 
235
     work well.
 
236
    </P
 
237
></DD
 
238
></DL
 
239
></DIV
 
240
></DIV
 
241
><DIV
 
242
CLASS="NAVFOOTER"
 
243
><HR
 
244
ALIGN="LEFT"
 
245
WIDTH="100%"><TABLE
 
246
SUMMARY="Footer navigation table"
 
247
WIDTH="100%"
 
248
BORDER="0"
 
249
CELLPADDING="0"
 
250
CELLSPACING="0"
 
251
><TR
 
252
><TD
 
253
WIDTH="33%"
 
254
ALIGN="left"
 
255
VALIGN="top"
 
256
><A
 
257
HREF="gin-implementation.html"
 
258
ACCESSKEY="P"
 
259
>Prev</A
 
260
></TD
 
261
><TD
 
262
WIDTH="34%"
 
263
ALIGN="center"
 
264
VALIGN="top"
 
265
><A
 
266
HREF="index.html"
 
267
ACCESSKEY="H"
 
268
>Home</A
 
269
></TD
 
270
><TD
 
271
WIDTH="33%"
 
272
ALIGN="right"
 
273
VALIGN="top"
 
274
><A
 
275
HREF="gin-limit.html"
 
276
ACCESSKEY="N"
 
277
>Next</A
 
278
></TD
 
279
></TR
 
280
><TR
 
281
><TD
 
282
WIDTH="33%"
 
283
ALIGN="left"
 
284
VALIGN="top"
 
285
>Implementation</TD
 
286
><TD
 
287
WIDTH="34%"
 
288
ALIGN="center"
 
289
VALIGN="top"
 
290
><A
 
291
HREF="gin.html"
 
292
ACCESSKEY="U"
 
293
>Up</A
 
294
></TD
 
295
><TD
 
296
WIDTH="33%"
 
297
ALIGN="right"
 
298
VALIGN="top"
 
299
>Limitations</TD
 
300
></TR
 
301
></TABLE
 
302
></DIV
 
303
></BODY
 
304
></HTML
 
305
>
 
 
b'\\ No newline at end of file'