PostgreSQL日常所需要的相关操作
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PostgreSQL日常所需要的相关操作相关的知识,希望对你有一定的参考价值。
记录下postgresql相关操作 一天一次 ANALYZE tb_events_col;
一周一次 VACUUM FULL
查询正在运行的任务 select * from pg_stat_activity where current_query!=<IDLE>
insert into oss_tb_events_202001_w select * from tb_events_col where start_time >= 2020-01-01::timestamp and start_time < 2020-02-01::timestamp;
insert into oss_tb_events_202002_w select * from tb_events_col_202002;
TRUNCATE tb_events_col_202002
select pg_terminate_backend(32789);
SELECT * FROM pg_stat_activity where current_query !=<IDLE>;
select pg_size_pretty(pg_total_relation_size(tb_events_col));
ANALYZE tb_events_col_202002
VACUUM tb_events_col_202002
VACUUM FULL tb_anchor_fans_col
select oid, relname from pg_class where relname =tb_anchor_fans_col; select * from gp_toolkit.gp_bloat_expected_pages where btdrelid =40653 select * from gp_toolkit.__gp_aovisimap_compaction_info(tb_anchor_fans_col::regclass);
select oid, relname from pg_class where relname =tb_fans_col; select * from gp_toolkit.gp_bloat_expected_pages where btdrelid =40604 select * from gp_toolkit.__gp_aovisimap_compaction_info(tb_anchor_fans_col::regclass); SELECT * FROM pg_stat_activity where current_query !=<IDLE>; show gp_appendonly_compaction_threshold
TRUNCATE TABLE tb_anchor_fans_col_bak
select pg_size_pretty(pg_relation_size(user_access_path)); select pg_size_pretty(pg_total_relation_size(tb_events_col));
VACUUM FULL tb_events_col ANALYZE tb_events_col_202003
delete from tb_events_col where id in ( SELECT id FROM tb_events_col where start_time < 2020-03-01::timestamp)
select gp_execution_dbid(),pg_size_pretty(pg_total_relation_size(tb_events_col))from gp_dist_random(gp_id);
杀logstash进程 initctl stop logstash
以上是关于PostgreSQL日常所需要的相关操作的主要内容,如果未能解决你的问题,请参考以下文章
PostgreSQL连接python,postgresql在python 连接,创建表,创建表内容,插入操作,选择操作,更新操作,删除操作。