![]() Like GiST, SP-GiST and GIN, BRIN can support many different indexing strategies, and the particular operators with which a BRIN index can be used vary depending on the indexing strategy. For more information see Chapter 61.īRIN indexes (a shorthand for Block Range indexes) store summaries about the values stored in consecutive table physical block ranges. Many other GIN operator classes are available in the contrib collection or as separate projects. (See Section 9.18 for the meaning of these operators.) The GIN operator classes included in the standard distribution are documented in Table 61-1. As an example, the standard distribution of PostgreSQL includes GIN operator classes for one-dimensional arrays, which support indexed queries using these operators: Like GiST and SP-GiST, GIN can support many different user-defined indexing strategies and the particular operators with which a GIN index can be used vary depending on the indexing strategy. GIN indexes are inverted indexes which can handle values that contain more than one key, arrays for example. (See Section 9.11 for the meaning of these operators.) The SP-GiST operator classes included in the standard distribution are documented in Table 60-1. As an example, the standard distribution of PostgreSQL includes SP-GiST operator classes for two-dimensional points, which support indexed queries using these operators: > SP-GiST permits implementation of a wide range of different non-balanced disk-based data structures, such as quadtrees, k-d trees, and radix trees (tries). SP-GiST indexes, like GiST indexes, offer an infrastructure that supports various kinds of searches. In Table 59-1, operators that can be used in this way are listed in the column "Ordering Operators". The ability to do this is again dependent on the particular operator class being used. Which finds the ten places closest to a given target point. As an example, the standard distribution of PostgreSQL includes GiST operator classes for several two-dimensional geometric data types, which support indexed queries using these operators: point '(101,456)' LIMIT 10 Accordingly, the particular operators with which a GiST index can be used vary depending on the indexing strategy (the operator class). ![]() GiST indexes are not a single kind of index, but rather an infrastructure within which many different indexing strategies can be implemented. For these reasons, hash index use is presently discouraged. Also, changes to hash indexes are not replicated over streaming or file-based replication after the initial base backup, so they give wrong answers to queries that subsequently use them. Hash index operations are not presently WAL-logged, so hash indexes might need to be rebuilt with REINDEX after a database crash if there were unwritten changes. The following command is used to create a hash index: CREATE INDEX name ON table USING HASH ( column) The query planner will consider using a hash index whenever an indexed column is involved in a comparison using the = operator. ![]() Hash indexes can only handle simple equality comparisons. This is not always faster than a simple scan and sort, but it is often helpful. It is also possible to use B-tree indexes for ILIKE and ~*, but only if the pattern starts with non-alphabetic characters, i.e., characters that are not affected by upper/lower case conversion.ī-tree indexes can also be used to retrieve data in sorted order. However, if your database does not use the C locale you will need to create the index with a special operator class to support indexing of pattern-matching queries see Section 11.9 below. The optimizer can also use a B-tree index for queries involving the pattern matching operators LIKE and ~ if the pattern is a constant and is anchored to the beginning of the string - for example, col LIKE 'foo%' or col ~ '^foo', but not col LIKE '%bar'. Also, an IS NULL or IS NOT NULL condition on an index column can be used with a B-tree index. In particular, the PostgreSQL query planner will consider using a B-tree index whenever an indexed column is involved in a comparison using one of these operators: =Ĭonstructs equivalent to combinations of these operators, such as BETWEEN and IN, can also be implemented with a B-tree index search. ![]() By default, the CREATE INDEX command creates B-tree indexes, which fit the most common situations.ī-trees can handle equality and range queries on data that can be sorted into some ordering. Each index type uses a different algorithm that is best suited to different types of queries. PostgreSQL provides several index types: B-tree, Hash, GiST, SP-GiST, GIN and BRIN. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |