postgresql 定时vacuum脚本

postgresql 定时vacuum脚本,第1张

概述# -*- coding: utf-8 -*-import pg,multiprocessinglst=[{"dbname":"postgres","host":"127.0.01","port":5432,"user":"postgres","passwd":"123456"},]def exe_job(item): try: db = pg.DB(dbn
# -*- Coding: utf-8 -*-import pg,multiprocessinglst=[{"dbname":"postgres","host":"127.0.01","port":5432,"user":"postgres","passwd":"123456"},]def exe_job(item):    try:        db = pg.DB(dbname=item['dbname'],host=item['host'],port=item['port'],user=item['user'],passwd=item['passwd'])        for table in db.get_tables():            db.query("VACUUM %s ;" %(table))            db.query("analyze %s ;" %(table))            print("%s %s" % (item['dbname'],table))    except Exception as e:        print(e)    finally:        db.close()if __name__ == '__main__':    pool_size=16    pool = multiprocessing.Pool(processes=pool_size)    pool.map(exe_job,lst)    pool.close() # no more tasks    pool.join()  # wrap up current tasks
总结

以上是内存溢出为你收集整理的postgresql 定时vacuum脚本全部内容,希望文章能够帮你解决postgresql 定时vacuum脚本所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/1172637.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存