# -*- 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脚本所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)