PostgreSQL Index Expansion

Source: Internet
Author: User
Tags postgresql

Index expansion, mainly for B-tree

Several sources of index bloat:

After a large number of deletions, the index pages are sparse, which reduces the efficiency of indexing;

PG9.0 the previous version, vacuum full will also cause the index page sparse;

Long-running transactions that prohibit vacuum cleanup of the table two cause the page sparse state to persist consistently.

Note that Reindex will cause full table lock, do not operate when the system is busy

To view the space occupied by the index:

Select Pg_relation_size (OID)/1024/1024,relname from Pg_class where relkind= ' i ' ORDER by pg_relation_size (OID) desc limit 20;

To view a specific index size

Select Pg_relation_size (' tbl_test_p1_pk ')/1024/1024;

Rebuilding a specific index

Reindex index TBL_TEST_P1_PK;

Update STATISTICS for a database

Analyze tbl_test;

To view a specific index size

Select Pg_relation_size (' tbl_test_p1_pk ')/1024/1024;

PostgreSQL Index Expansion

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.