PostgreSQL: tablespace

Source: Internet
Author: User

PostgreSQL provides a simple description of table space for two reasons:

    • Expand the storage space, jump out of the OS's file system size limit, and constantly expand the available space
    • Let the database administrator optimize the system performance according to the application characteristics of the system.

 

The tablespace of PostgreSQL is the dedicated OS directory (PATH) for PostgreSQL ). Nothing mysterious. Creating multiple tablespaces in a logical file system makes little sense, because you cannot control a single file in a logical file system.

 

Create tablespace tbl_name location 'OS _ dir_path_str'; -- The OS _path must be empty and the Directory authorized by the PostgreSQL account. The user who creates a tablespace must be a superuser. After creating a tablespace, you can grant the create permission for the tablespace to common users!

 

Specify tablespace and default tablespace

    • Table space objects: tables, indexes, and databases: when creating these objects, You can explicitly specify the tablespace tals_name clause to indicate the table space used by the object;
    • If this parameter is not specified, the system uses the currently valid default tablespace.
    • Similarly, the index and internal temporary table of the temporary table and temporary table also have the default temporary table space. When you specify system parameters for temporary tablespace, you can specify multiple tablespaces. PostgreSQL will randomly use them.
    • Two default tablespace pg_global and pg_default initialized by initdb.exe
    • The default tablespace pg_default in the database is used to store the default space of system directory objects, user tables, user table indexes, and temporary tables, temporary table indexes, and internal temporary tables. It is the default tablespace of the template0 and template1 template databases.
    • The default tablespace pg_global in the database is used to store the default space of the shared system directory.
    • The default tablespace of the database can be changed in the create database using the tablespace tbs_anme clause.

 

 

Tablespaces are independent of a single database and are used by all databases. Therefore, the tablespace can be dropped only when no objects are used!

 

PostgreSQL allows you to simplify the implementation of tablespaces through symbolic links. On OS that do not support symbolic links, you can only explicitly create the required tablespaces!

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.