我如何告诉Django使用10MB语句mem执行所有查询? [英] How can I tell Django to execute all queries using 10MB statement mem?

查看:153
本文介绍了我如何告诉Django使用10MB语句mem执行所有查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Django与postgresql数据库。



我对数据库配置的访问非常有限,不能更改 postgresql。 conf



但是,如果我想通过django执行所有查询,并指定 statement_mem 设置说10MB。



我尝试使用 cursor.execute(set statement_mem ='10MB') - 它正在工作,但是如何用通用的方式写 - 所以每个API调用都会使用这个设置?

解决方案

您自己的类中的游标在每个调用上执行 cursor.execute(set statement_mem ='10MB'),但是可以模拟游标类。您可以monkeypatch真正的游标类,但这可能会令人困惑。


I'm using Django with postgresql database.

I'm having very limited access for database configuration and can't alter postgresql.conf.

However if I want to execute all queries through django with specified statement_mem settings say 10MB.

I tried using cursor.execute("set statement_mem='10MB'") - it is working but how can I write it in generic way - so each every API calls go using by this setting?

解决方案

Wrap the cursor in your own class that executes cursor.execute("set statement_mem='10MB'") on every call but otherwise mimics the cursor class. You could "monkeypatch" the real cursor class too, but this could be confusing.

这篇关于我如何告诉Django使用10MB语句mem执行所有查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆