Question

Why is postgres slow when data is stored in a Volume as opposed to the local filing system?

Hi, I’m using a postgres database deployed as a docker container on a $15/mo Droplet (with swap). I’ve replicated the container for an A vs. B ‘Volume vs local filing system’ speed test.

Where the database files are : [A] on local machine file system/disk <---- takes 10s [B] on a 10GB Volume <— takes 34s

A query on a 7 million row table (see below) takes 10 secs on [A] and 34 secs on [B]

SELECT * FROM ( SELECT val1,val2, cdatetime, a, b, c, d FROM events_table WHERE cdatetime >= ‘2022-01-16T12:26’ AND cdatetime < ‘2022-01-17T15:26’ ORDER BY cdatetime DESC ) as sub_sigevent WHERE sub_sigevent.d = 59 AND sub_sigevent.a = 6 AND sub_sigevent.b = 3 AND sub_sigevent.c = 7

As Volumes are networked memory in effect, I assume this is caused by the slow connection to the Volume compared to local filing system. So it would appear there’s no way round this, other than to try a time series specific data base such as ClickHouse (OSS version of InfluxDB) that scales better.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello. Did you manage to relive this issue?

Hi there,

I was just about to share the link to the same discussion. Indeed as mentioned in that discussion, you will always see a bit worse performance on a Volume compared to local storage, as Volumes are network-based storage which adds some overhead.

You could try doing some tweaking in order to optimize the performance of the Postgres instance itself using the following script:

https://github.com/jfcoz/postgresqltuner

Also, a good related read would be this tutorial here on how to benchmark DigitalOcean volumes:

https://www.digitalocean.com/community/tutorials/how-to-benchmark-digitalocean-volumes

Best, Bobby