PostgreSQL Index Classification and usage

Source: Internet
Author: User

1. Indexing method

The PostgreSQL database supports single index, multi-column composite index, part index, unique index, expression index, implied index, and concurrent index.

2. Indexing methods

PostgreSQL supports B-tree, hash, GiST, and GIN index methods.

3. Index Use Range

1). B-tree

B-tree can be used effectively when a query contains an equals sign (=) and a range operator (<, <=,, >=, between, and in).

2). Hash

An equals sign operator (=), which is not suitable for range operators.

3). Gist

Applies to custom complex types, including Rtree_gist, Btree_gist, Intarray,tsearch, Ltree, and Cube.

4). GIN

Gin occupies more than three times times more space than gist, and is suitable for complex like such as '%abc12% '.

4. Index usage Precautions

1). When a table has many rows, it is important to index a table column.

2). When retrieving data, it is important to select a good alternate column as the index, foreign key, or key with the maximum minimum value, and the selectivity of the column is critical to the validity of the index.

3). For better performance to remove unused indexes, rebuild all indexes every January in order to clear the unusable rows.

4). If there is a very large amount of data, use the table partitioning index.

5) When a column contains a null value, consider establishing a conditional index that does not contain null.

This article is from the "Yiyi" blog, make sure to keep this source http://heyiyi.blog.51cto.com/205455/1783945

PostgreSQL Index Classification and usage

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.