当前位置:网站首页>PostgreSQL age XID maintenance prevents the database from being read-only
PostgreSQL age XID maintenance prevents the database from being read-only
2022-06-12 04:34:00 【Python's path to becoming a God】
select * from
(SELECT c.oid::regclass as table_name, greatest(age(c.relfrozenxid),age(t.relfrozenxid)) as age FROM pg_class c LEFT JOIN pg_class t ON c.reltoastrelid = t.oid WHERE c.relkind IN ('r', 'm')
order by age desc) tmp
where age>=1002644113
It is recommended to use vacuum freeze [ table_name ] To the specified table xid Freeze cleaning .
Reference link :
https://blog.csdn.net/weixin_39803207/article/details/111882812
SELECT datname,max(age(datfrozenxid)) FROM pg_database
GROUP BY datname
// Query other databases age The larger
update pg_database set datallowconn = TRUE where datname = 'template0';
/opt/pgsql/bin/vacuumdb --freeze template0
update pg_database set datallowconn = FALSE where datname = 'template0';
/opt/pgsql/bin/vacuumdb --freeze template1
/opt/pgsql/bin/vacuumdb --freeze postgres
// Query each database xid Maximum
SELECT datname,max(age(datfrozenxid)) FROM pg_database
GROUP BY datname
// Inquire about autovacuum Ongoing sql
SELECT
procpid,
start,
now() - start AS lap,
current_query
FROM
(SELECT
backendid,
pg_stat_get_backend_pid(S.backendid) AS procpid,
pg_stat_get_backend_activity_start(S.backendid) AS start,
pg_stat_get_backend_activity(S.backendid) AS current_query
FROM
(SELECT pg_stat_get_backend_idset() AS backendid) AS S
) AS S
WHERE
current_query <> '<IDLE>'
and current_query like '%vacuum%'
ORDER BY
start DESC;
// Batch freeze scripts
#!/bin/bash
for i in `/opt/pgsql/bin/psql auditdb auditor -c "SELECT c.oid::regclass as table_name, greatest(age(c.relfrozenxid),age(t.relfrozenxid)) as age FROM pg_class c LEFT JOIN pg_class t ON c.reltoastrelid = t.oid WHERE c.relkind IN ('r', 'm') order by age desc limit 30" | grep 't_'`
do
echo $i | grep 't' > /dev/null
if [ $? -eq 0 ]; then
echo $i
fsql="vacuum freeze $i"
/opt/pgsql/bin/psql auditdb auditor -c "$fsql"
fi
done
边栏推荐
- Enterprise Architect v16
- Bearpi IOT lighting LED
- How to use union all in LINQ- How to use union all in LINQ?
- Oracle paging query ~~rownum (line number)
- [automation] generate xlsx report based on openstack automated patrol deployed by kolla
- 【C语言】程序的内存四区模型
- Detailed explanation of software testing process
- AI and logistics Patent
- 后续版本是否会支持代码块搜索高亮显示
- Summary of sequential, modulelist, and moduledict usage in pytorch
猜你喜欢

SQL注入上传一句话木马(转)

eBPF系列学习(4)了解libbpf、CO-RE (Compile Once – Run Everywhe) | 使用go开发ebpf程序(云原生利器cilium ebpf )

1. Mx6ull learning notes (II) - uboot migration

命令执行漏洞详解

Mysql主从搭建与Django实现读写分离
![[official testerhome] MTSC 2021 Shanghai and Shenzhen PPT download addresses](/img/a0/d1170b20d01a7a586d8ff68279f1d4.jpg)
[official testerhome] MTSC 2021 Shanghai and Shenzhen PPT download addresses

How to use union all in LINQ- How to use union all in LINQ?

图解 Apache SkyWalking UI 的使用

QT compiling security video monitoring system 43- picture playback
![[software tool] [original] tutorial on using VOC dataset class alias batch modification tool](/img/25/31d771c9770bb7f455f35e38672170.png)
[software tool] [original] tutorial on using VOC dataset class alias batch modification tool
随机推荐
In the era of smart retail, Weimeng reshapes the value of "shopping guide"
JS function and variable have the same name (function and variable parsing rules)
PHP and JS remove all spaces
如何制作数据集并基于yolov5训练成模型并部署
Sqel easy to use
Detailed explanation of Command Execution Vulnerability
Zabbix6.0 new feature GEOMAP map marker can you use it?
2022 electrician (elementary) operation certificate examination question bank and online simulation examination
What are the black box test case design methods in software testing methods?
[fpga+fft] design and implementation of FFT frequency meter based on FPGA
[automation] generate xlsx report based on openstack automated patrol deployed by kolla
WiFi module scheme of the wireless Internet of things, esp32-s3 chip technology, helps the equipment to be intelligent
Thousand word masterpiece "programming biography"
MySQL master-slave construction and Django implementation of read-write separation
How Windows installs multiple versions of MySQL and starts it at the same time
1. Mx6ull learning notes (II) - uboot migration
Oracle's instr()
Daily practice (28): balance binary tree
疫情数据分析平台工作报告【8.5】额外的爬虫和绘图
Illustrating the use of Apache skywalking UI