psuderevsky@gmail.com writes:
> [ query producing a 46-million-row join result ]
> Observing amount of memory consumed by psql process with pmap utility...
> So about 8Gb of linux virtual memory has been allocated for join of two
> tables with sizes of 11MB.
> The question is why so high amount of virtual memory is consumed, isn't it
> a memory leak.
No, it's just a very large query result. psql collects the entire query
result into memory before printing any of it, so that it can format the
result nicely. If you're dealing with query results large enough for that
to be a problem, you could consider using psql's FETCH_COUNT variable to
make it fetch and format a smaller number of rows at a time; which would
trade off the niceness of the formatting for less memory usage.
regards, tom lane