1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
12
TITLE="PostgreSQL 9.1beta1 Documentation"
13
HREF="index.html"><LINK
15
TITLE="Index Access Method Interface Definition"
16
HREF="indexam.html"><LINK
18
TITLE="Index Access Method Functions"
19
HREF="index-functions.html"><LINK
21
TITLE="Index Locking Considerations"
22
HREF="index-locking.html"><LINK
25
HREF="stylesheet.css"><META
26
HTTP-EQUIV="Content-Type"
27
CONTENT="text/html; charset=ISO-8859-1"><META
29
CONTENT="2011-04-27T21:20:33"></HEAD
35
SUMMARY="Header navigation table"
47
>PostgreSQL 9.1beta1 Documentation</A
56
TITLE="Index Access Method Functions"
57
HREF="index-functions.html"
66
TITLE="Index Access Method Interface Definition"
74
>Chapter 52. Index Access Method Interface Definition</TD
80
TITLE="Index Access Method Interface Definition"
89
TITLE="Index Locking Considerations"
90
HREF="index-locking.html"
104
NAME="INDEX-SCANNING"
105
>52.3. Index Scanning</A
108
> In an index scan, the index access method is responsible for regurgitating
109
the TIDs of all the tuples it has been told about that match the
113
>. The access method is <SPAN
120
actually fetching those tuples from the index's parent table, nor in
121
determining whether they pass the scan's time qualification test or other
125
> A scan key is the internal representation of a <TT
145
>, where the index key is one of the columns of the
146
index and the operator is one of the members of the operator family
147
associated with that index column. An index scan has zero or more scan
148
keys, which are implicitly ANDed — the returned tuples are expected
149
to satisfy all the indicated conditions.
152
> The access method can report that the index is <I
156
requires rechecks, for a particular query. This implies that the index
157
scan will return all the entries that pass the scan key, plus possibly
158
additional entries that do not. The core system's index-scan machinery
159
will then apply the index conditions again to the heap tuple to verify
160
whether or not it really should be selected. If the recheck option is not
161
specified, the index scan must return exactly the set of matching entries.
164
> Note that it is entirely up to the access method to ensure that it
165
correctly finds all and only the entries passing all the given scan keys.
166
Also, the core system will simply hand off all the <TT
170
clauses that match the index keys and operator families, without any
171
semantic analysis to determine whether they are redundant or
172
contradictory. As an example, given
175
>WHERE x > 4 AND x > 14</TT
180
indexed column, it is left to the b-tree <CODE
184
to realize that the first scan key is redundant and can be discarded.
185
The extent of preprocessing needed during <CODE
189
depend on the extent to which the index access method needs to reduce
190
the scan keys to a <SPAN
196
> Some access methods return index entries in a well-defined order, others
197
do not. There are actually two different ways that an access method can
198
support sorted output:
205
> Access methods that always return entries in the natural ordering
206
of their data (such as btree) should set
214
Currently, such access methods must use btree-compatible strategy
215
numbers for their equality and ordering operators.
220
> Access methods that support ordering operators should set
228
This indicates that the index is capable of returning entries in
229
an order satisfying <TT
249
of that form can be passed to <CODE
267
which can be either <TT
269
>ForwardScanDirection</TT
273
>BackwardScanDirection</TT
274
>. If the first call after
280
>BackwardScanDirection</TT
282
set of matching index entries is to be scanned back-to-front rather than in
283
the normal front-to-back direction, so <CODE
287
the last matching tuple in the index, rather than the first one as it
288
normally would. (This will only occur for access
292
> to true.) After the
296
> must be prepared to advance the scan in
297
either direction from the most recently returned entry. (But if
304
> is false, all subsequent
305
calls will have the same direction as the first one.)
308
> Access methods that support ordered scans must support <SPAN
312
position in a scan and later returning to the marked position. The same
313
position might be restored multiple times. However, only one position need
314
be remembered per scan; a new <CODE
318
previously marked position. An access method that does not support
319
ordered scans should still provide mark and restore functions in
323
>, but it is sufficient to have them throw errors if
327
> Both the scan position and the mark position (if any) must be maintained
328
consistently in the face of concurrent insertions or deletions in the
329
index. It is OK if a freshly-inserted entry is not returned by a scan that
330
would have found the entry if it had existed when the scan started, or for
331
the scan to return such an entry upon rescanning or backing
332
up even though it had not been returned the first time through. Similarly,
333
a concurrent delete might or might not be reflected in the results of a scan.
334
What is important is that insertions or deletions not cause the scan to
335
miss or multiply return entries that were not themselves being inserted or
339
> Instead of using <CODE
342
>, an index scan can be done with
346
> to fetch all tuples in one call. This can be
347
noticeably more efficient than <CODE
351
avoiding lock/unlock cycles within the access method. In principle
355
> should have the same effects as repeated
359
> calls, but we impose several restrictions to
360
simplify matters. First of all, <CODE
364
tuples at once and marking or restoring scan positions isn't
365
supported. Secondly, the tuples are returned in a bitmap which doesn't
366
have any specific ordering, which is why <CODE
373
> argument. (Ordering operators will never be
374
supplied for such a scan, either.) Finally, <CODE
378
does not guarantee any locking of the returned tuples, with implications
380
HREF="index-locking.html"
385
> Note that it is permitted for an access method to implement only
393
if its internal implementation is unsuited to one API or the other.
401
SUMMARY="Footer navigation table"
412
HREF="index-functions.html"
430
HREF="index-locking.html"
440
>Index Access Method Functions</TD
454
>Index Locking Considerations</TD
b'\\ No newline at end of file'