7

I have a Postgres database inside a docker container against which I run django tests. I want to improve the speed of the tests. The easiest way to do this (it seems to me) is to move postgres data into tmpfs volume.

Here's what I did:

docker run --name my_tfmps_test -d -p 5432:5432 \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=my_database \
-e PGDATA=/var/lib/postgresql/data \
--tmpfs /var/lib/postgresql/data \
library/postgres

Because I specified --tmpfs I expect the tests run significantly faster. Unfortunately this is not the case. The speed of the tests remains exactly on the same level (give or take 5%).

My questions is: why did the speed of the tests did not change? And what can I do about it ?

Extra info:

4

1 回答 1

8

我的问题是:为什么测试的速度没有改变?我能做些什么呢?

如果表太小以至于它已经适合 ram,则 tmpfs 不会为您带来太多好处,除了几次刷新到磁盘。而且,如果该磁盘是 SSD,那么它根本就不多。通常,您可以通过关闭Durability Options使您的测试套件运行得更快。

于 2018-09-11T14:12:50.973 回答