If you have to parse and plan queries every time PostgreSQL is obviously much slower than Redis. It is much more interesting to see what happens if prepared statements are used.
And having a locking system fluctuate in latency between milliseconds and seconds would cause all sorts of headaches.
> And having a locking system fluctuate in latency between milliseconds and seconds would cause all sorts of headaches.
With the frequency that a locking system is likely to be used, it’s highly unlikely that those pages would ever get purged from the buffer pool.
a) Writes will be happening on a slow, highly contentious disk.
b) You have no guarantees that the data will be in-memory.
Both of which make it a poor solution for use cases such as locking.
That's fine. If what you want is a single-node deployment combined with in-memory purism them SQLite has your back.
https://github.com/raphaeldelio/redis-postgres-cache-benchma...
Postgres has a shared memory cache, which can be set the same as redis, so your operations will all happen with in memory, with some background stuff putting it onto disk for you in the case your computer shuts off. Storage won't be involved.
BUT, postgres still has ~6x the latency [1], even when run from memory.
[1] https://medium.com/redis-with-raphael-de-lio/can-postgres-re....