PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16363
PG Version12.2
OSUbuntu Linux 19.04
Opened2020-04-14 23:11:39+00
Reported byEduardo Barreto Alenxadre
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16363
Logged by:          Eduardo Barreto Alenxadre
Email address:      (redacted)
PostgreSQL version: 12.2
Operating system:   Ubuntu Linux 19.04
Description:        

I have a specific use case when I need a lot of similar tables in my
database, in one case, for example, I have more than 700 tables.

Whenever I insert data in one of these tables within the same connection,
the memory used by that connection process will increase and never be freed
(unless I close the connection), because of that I'm getting Out Of Memory
errors in my backend since the connection eventually consumes the entire
memory available in my system.

Looking around I found this issue in StackOverflow which I think is exactly
the issue I'm having:
https://stackoverflow.com/questions/5587830/postgresql-backend-process-high-memory-usage-issue

I'm not sure if this is a memory leak or simply a cache mechanism of
Postgres, if the later, can I control it somehow to force it to free
memory?

just for completeness, this is a table of the memory usage of a single
Postgres connection process running a script that will simply insert new
data randomly in these 700 tables one at a time.

# Elapsed time   Real (MB)   Virtual (MB)
       0.000        26.453      328.066
      20.017       421.367      766.164
      40.037       889.867     1302.520
      60.057      1305.645     1772.336
      80.077      1681.555     2243.105
     100.093      2001.133     2679.195
     120.109      2333.535     3131.918
     140.129      2622.051     3518.801
     160.141      2887.207     3886.355
     180.157      3209.109     4323.109
     200.177      3414.656     4606.566
     220.197      3414.656     4606.566
     240.218      3414.656     4606.566

After the last line, I got OOM error.

Messages

DateAuthorSubject
2020-04-14 23:11:39+00PG Bug reporting formBUG #16363: Memory increases for each table accessed until connection is closed
2020-04-15 01:48:31+00Tom LaneRe: BUG #16363: Memory increases for each table accessed until connection is closed
2020-04-16 14:18:04+00Eduardo Barreto AlexandreRe: BUG #16363: Memory increases for each table accessed until connection is closed
2020-04-16 14:43:16+00luis(dot)roberto(at)siscobra(dot)com(dot)brRe: BUG #16363: Memory increases for each table accessed until connection is closed
2020-04-16 21:23:33+00Eduardo Barreto AlexandreRe: BUG #16363: Memory increases for each table accessed until connection is closed
2020-04-16 21:36:56+00Tomas VondraRe: BUG #16363: Memory increases for each table accessed until connection is closed
2020-04-17 19:17:10+00Eduardo Barreto AlexandreRe: BUG #16363: Memory increases for each table accessed until connection is closed