内存数据库中的Postgresql django [英] Postgresql in memory database django

查看:200
本文介绍了内存数据库中的Postgresql django的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于性能问题,我想在django中的内存数据库中执行一个优化算法(我很可能会执行很多查询)。我知道可以在内存中使用sqlite(如何运行Django的测试数据库仅在内存中?),但我宁愿使用postgresql,因为我们的prod数据库是一个postgresql的。有没有人知道如何告诉django在内存中创建postgresql数据库?





提前感谢

解决方案

这是过早的优化。即使您运行在冷金属硬盘上,Postgresql也非常快,只要您使用正确的索引。如果你不坚持在磁盘上的数据,那么你可以打开自己一个痛苦的世界。



另一方面,如果你想通过运行加速测试一个在内存中的postgresql数据库,你可以尝试类似这些非耐久性优化



http://www.postgresql.org/docs/9.1/static/non-durability.html



最激烈的建议是在该页面上使用 ramdisk 如何设置一个。在遵循OS / Postgresql步骤后,编辑django settings.py并将表空间添加到DATABASES部分。



最后但并非最不重要的:这只是一个完全浪费时间。


For performance issues I would like to execute an optimization algorithm on an in memory database in django (I'm likely to execute a lot of queries). I know it's possible to use a sqlite in memory (How to run Django's test database only in memory?) but I would rather use postgresql because our prod database is a postgresql one.

Does someone knows how to tell django to create the postgresql database in the memory ?

Thanks in advance

解决方案

This is premature optimization. Postgresql is very very fast even if you are running it on a cold metal hard disk provided you use the right indexes. If you don't persist the data on disk, you are opening yourself upto a world of pain.

If on the other hand you want to speed up your tests by running an in memory postgresql database you can try something like these non durability optimizations:

http://www.postgresql.org/docs/9.1/static/non-durability.html

The most drastic suggestion is to use a ramdisk on that page. Here's how to set up one. After following the OS/Postgresql steps edit django settings.py and add the tablespace to the DATABASES section.

Last but not least: This is just a complete waste of time.

这篇关于内存数据库中的Postgresql django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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