Well, it seems that your queries are using the amount of memory over your available. Therefore, you should look at the query execution plan and find the biggest loads. These queries exceed the memory available for postgresql. Usually excessive aggregation (i.e., a poor database structure that would be better denonarmalized, if applicable) or a lot of nested queries or queries with IN clauses are typical suspects. I assume that amazon is delivered as much as possible for postgresql.conf, and these default values are not bad for this tiny machine.
But again, if your swap size does not exceed your available memory, and you are on an SSD - there would be no harm to it
source
share