Are you using postgres on the same server, or is it over a network. If it is over the network it could be that there is considerable latency, especially if you are accessing a postgres server over the internet (WAN) instead over LAN.
The older libpg should not be a massive issue, but it depends solely on how old the version used is, and also whether there was any major issues patched in the newer versions, or if it was just small fixes. You have to bare in mind, although postgres is fast compared to other SQL servers, it still is bottlenecked by the complexity of sql, and it also depends on the complexity of the tables, if the tables within the database are very complex there is additional overhead. If you are writing large amounts of data to and from a postgres server, I highly recommend using a cache, either storing the data on memory and using a thread which syncs it with the database every x period (x being a set period of your desire, more often == more data stability, in case of sudden shutdown, but higher overhead). Furthermore, if you are caching in memory all the data you need, you should be able to easily use a separate thread for syncing the data with the persistent database. Or you could use @treeform idea of using async, and use a postgres pool, and each time you want to modify the data, you modify the data in memory and then pass this data into a async task which syncs it with the database, this means that the data can be accessed quickly because it is on memory, and also has the stability of a persistent database which is updated immediately, the only downside is that having a pool and async tasks does have overhead, but being lightweight and speed often go against one another, lightweight implies a low memory fingerprint, while speed uses memory to reduce the latency of fetching data, more you cache in memory the less latency you have fetching from disk, or even worse, over the network! TLDR: The speed of postgres depends on the complexity of the database and also where the server is running, other factors can affect the speed of the database operations. If you need fast data access and modification, using a persistent database directly is slow, you should use a cache in memory to do so. Hope this helps :)