7.postgresql表空间指定不同的磁盘路径

postgresql表空间指定不同的磁盘路径

案例

postgres=# \db
       List of tablespaces
    Name    |  Owner   | Location 
------------+----------+----------
 pg_default | postgres | 
 pg_global  | postgres | 
(2 rows)
postgres=# create tablespace mytb1 location '/home/postgres/tbls_a';
CREATE TABLESPACE
postgres=# \db mytb1
           List of tablespaces
 Name  |  Owner   |       Location        
-------+----------+-----------------------
 mytb1 | postgres | /home/postgres/tbls_a
(1 row)
postgres=# create table t(i int) tablespace mytb1;
CREATE TABLE
postgres=# 

使用表空间的优点

  • 分散IO
  • 存储扩容
  • 限制单个table或db的size
  • 对不同的磁盘进行参数调优
  • 单独设置临时文件的路径
posted @ 2026-05-12 16:20  数据库小白(专注)  阅读(13)  评论(0)    收藏  举报