PostgreSQL-臨時表空間與配置表


雖然我給數據庫創建了表空間,但是操作中仍遇到了些問題,需要創建臨時表空間。

 

配置表

首先了解下 postgres 的配置表,手動修改各種配置。

打開即可看到各種配置,包括臨時表空間。

 

臨時表空間

1. postgres 有默認的臨時表空間,可手動修改

2. postgres 的臨時表空間用來存儲臨時表或者臨時表的索引,而且某些sql語句也會產生臨時文件,如排序、聚合等,也需要臨時表空間

3. 即使設置了表空間,臨時表和臨時文件也不會自動存儲到表空間,仍存儲在默認的臨時表空間

4. 修改臨時表空間需要配置 temp_tablespaces 參數,postgres 允許設置多個臨時表空間,使用逗號隔開

5. 為了提高性能,臨時表空間一般放在SSD或者IOPS,以及吞吐量較高的分區中

 

修改臨時表空間首先要創建表空間  【方法就是單純創建表空間的方法】

$ mkdir -p /data/pg_data/temp_tsp
$ chown -R postgres:postgres /data/pg_data/temp_tsp
postgres=# CREATE TABLESPACE temp01 LOCATION '/data/pg_data/temp_tsp';
CREATE TABLESPACE

 

設置臨時表空間 -- 會話級生效

[root@localhost ~]# su postgres
bash-4.2$ psql
could not change directory to "/root"
psql (9.2.24)
Type "help" for help.

postgres=# set temp_tablespaces = 'zns_road';
SET

 

查看臨時表空間

postgres=# show temp_tablespaces ;
 temp_tablespaces 
------------------
 zns_road
(1 row)

設置成功;

 

關閉會話后,重新查看

postgres=# show temp_tablespaces;
 temp_tablespaces 
------------------
 
(1 row)

不存在了。

 

修改配置文件 -- 永久生效

修改完畢后執行如下命令,修改才能生效。

pg_ctl reload

如果報錯,嘗試如下操作

bash-4.2$ ./pg_ctl -D /var/lib/pgsql/data reload
server signaled

詳情請參考下面鏈接,或 我的博客

 

 

參考資料:

https://blog.csdn.net/pg_hgdb/article/details/78712694  使用pg_ctl啟動數據庫時報錯

https://blog.csdn.net/jinshi366/article/details/80017541  pg_ctl: no database directory specified and environment variable PGDATA unset , centos 7 postgreSQL

https://blog.csdn.net/dracotianlong/article/details/7828515  pg_ctl -- 啟動、停止、重啟 PostgreSQL

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM