]> begriffs open source - ai-pg/blob - full-docs/txt/locking-indexes.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / locking-indexes.txt
1
2 13.7. Locking and Indexes #
3
4    Though PostgreSQL provides nonblocking read/write access to table data,
5    nonblocking read/write access is not currently offered for every index
6    access method implemented in PostgreSQL. The various index types are
7    handled as follows:
8
9    B-tree, GiST and SP-GiST indexes
10           Short-term share/exclusive page-level locks are used for
11           read/write access. Locks are released immediately after each
12           index row is fetched or inserted. These index types provide the
13           highest concurrency without deadlock conditions.
14
15    Hash indexes
16           Share/exclusive hash-bucket-level locks are used for read/write
17           access. Locks are released after the whole bucket is processed.
18           Bucket-level locks provide better concurrency than index-level
19           ones, but deadlock is possible since the locks are held longer
20           than one index operation.
21
22    GIN indexes
23           Short-term share/exclusive page-level locks are used for
24           read/write access. Locks are released immediately after each
25           index row is fetched or inserted. But note that insertion of a
26           GIN-indexed value usually produces several index key insertions
27           per row, so GIN might do substantial work for a single value's
28           insertion.
29
30    Currently, B-tree indexes offer the best performance for concurrent
31    applications; since they also have more features than hash indexes,
32    they are the recommended index type for concurrent applications that
33    need to index scalar data. When dealing with non-scalar data, B-trees
34    are not useful, and GiST, SP-GiST or GIN indexes should be used
35    instead.