1
- $Header: /cvsroot/pgsql/src/backend/access/hash/README,v 1.1 2003/09/01 20:24:49 tgl Exp $
1
+ $Header: /cvsroot/pgsql/src/backend/access/hash/README,v 1.2 2003/09/02 03:29:01 tgl Exp $
2
2
3
3
This directory contains an implementation of hash indexing for Postgres.
4
4
@@ -189,7 +189,7 @@ The insertion algorithm is rather similar:
189
189
read/sharelock meta page
190
190
compute bucket number for target hash key
191
191
release meta page
192
- share-lock bucket page (to prevent split/compact this bucket)
192
+ share-lock bucket page (to prevent split/compact of this bucket)
193
193
release page 0 share-lock
194
194
-- (so far same as reader)
195
195
read/exclusive-lock current page of bucket
@@ -334,7 +334,7 @@ Obtaining an overflow page:
334
334
release bitmap page
335
335
loop back to try next bitmap page, if any
336
336
-- here when we have checked all bitmap pages; we hold meta excl. lock
337
- extend index to add another bitmap page; update meta information
337
+ extend index to add another overflow page; update meta information
338
338
write/release meta page
339
339
return page number
340
340
@@ -344,6 +344,12 @@ concurrency against processes just entering the index. We don't want
344
344
to hold the metapage exclusive lock while reading in a bitmap page.
345
345
(We can at least avoid repeated buffer pin/unpin here.)
346
346
347
+ The normal path for extending the index does not require doing I/O while
348
+ holding the metapage lock. We do have to do I/O when the extension
349
+ requires adding a new bitmap page as well as the required overflow page
350
+ ... but that is an infrequent case, so the loss of concurrency seems
351
+ acceptable.
352
+
347
353
The portion of tuple insertion that calls the above subroutine looks
348
354
like this:
349
355
@@ -392,7 +398,12 @@ algorithm is:
392
398
release meta page
393
399
394
400
We have to do it this way because we must clear the bitmap bit before
395
- changing the first-free-bit field.
401
+ changing the first-free-bit field (hashm_firstfree). It is possible that
402
+ we set first-free-bit too small (because someone has already reused the
403
+ page we just freed), but that is okay; the only cost is the next overflow
404
+ page acquirer will scan more bitmap bits than he needs to. What must be
405
+ avoided is having first-free-bit greater than the actual first free bit,
406
+ because then that free page would never be found by searchers.
396
407
397
408
All the freespace operations should be called while holding no buffer
398
409
locks. Since they need no lmgr locks, deadlock is not possible.
0 commit comments