随笔分类 - PostgreSQL
摘要:#!/bin/bash ################################################################################################################################## # # Nam
阅读全文
摘要:#!/bin/bash ################################################## # # check_postgresql_db_table_rowsnum_and_sizing.sh # # This scripts iterates arti data
阅读全文
摘要:#!/bin/bash ################################################################ # # calculate_a_pure_size_of_the_postgres_db.sh # # This script calculate
阅读全文
摘要:This post demonstrates an example of a Bash script that connects to a DB and prints a list of tables, their records number, and size. The result set i
阅读全文
摘要:在Oracle数据库中,同义词(Synonym)是一个指向另一个对象(表、视图、函数等)的命名引用。在将Oracle数据库迁移到PostgreSQL时,由于PostgreSQL没有直接支持同义词的概念,因此需要采取一些策略来处理同义词的转换。 以下是一种常见的方法来处理同义词的转换: 创建视图: 在
阅读全文
摘要:select col.column_id, col.owner as schema_name, col.table_name, col.column_name, col.data_type, col.data_length, col.data_precision, col.data_scale, c
阅读全文
摘要:PG 参数PLAN_CACHE_MODE可以选择(FORCE_CUSTOM_PLAN 或 FORCE_GENERIC_PLAN)默认为auto . -- 通过 set修改 set PLAN_CACHE_MODE=FORCE_CUSTOM_PLAN; set PLAN_CACHE_MODE=FORCE
阅读全文
摘要:https://www.tutorialdba.com/2018/06/how-to-get-table-size-database-size_26.html
阅读全文
摘要:create extension pg_stat_statements; show shared_preload_libraries; Useful commands -- Flush data from pg_stat_statements: > pg_stat_statements_reset(
阅读全文
摘要:-- 查看正在执行index creation语句的持续时间,每隔2秒输出一次 SELECT now()::TIME(0), a.query, p.phase, p.blocks_total, p.blocks_done, p.tuples_total, p.tuples_done FROM pg_
阅读全文
摘要:pg_stat_progress_analyze pg_stat_progress_cluster pg_stat_progress_create_index pg_stat_progress_basebackup pg_stat_progress_copy pg_stat_progress_vac
阅读全文
摘要:-- https://dataegret.com/2017/10/deep-dive-into-postgres-stats-pg_stat_progress_vacuum/ SELECT p.pid, now() - a.xact_start AS duration, coalesce(wait_
阅读全文
摘要:select relname,relpages, reltuples from pg_class where relname='t1'; -- vacuum 清除 【每个块】的dead tuples,且不会将块的【位置】进行重组,不会更新表page的信息 vacuum t1; analyze t1;
阅读全文
摘要:PostgreSQL stderr日志记录,修改postgresql.cfg中的log_line_prefix: log_line_prefix = '%m [pid=%p] %q[txid=%x] %u@%d ' -- 输出结果如下 2024-06-20 17:17:52.988 CEST [pi
阅读全文
摘要:No space left on device - 背景:当插入数据很大导致磁盘空间爆满时,PG会启动自杀,然后回滚因导致磁盘饱满的操作之后,并自动恢复数据库 create table t2 (tz time, device_id int , cpu_usage float); insert int
阅读全文
摘要:PG EXPLAIN (query planner) Synopsis EXPLAIN [ ANALYZE ] [ VERBOSE ] statement where option can be one of: ANALYZE [ boolean ] VERBOSE [ boolean ] COST
阅读全文
摘要:扫盲 1. autofailover实际是使用repmgrd进程主动监控并执行主备切换,看上去很强大,实则生产中慎用或者不用。 2. PG switchover时,主备 PG owner 必须配置免密,并且 只能在standby机器上执行switchover的操作 系统环境 OS: CentOS7
阅读全文