OOM-killer issue when updating a inheritance table which has large number of child tables

From: chenhj <chjischj(at)163(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: OOM-killer issue when updating a inheritance table which has large number of child tables
Date: 2015-03-12 10:55:48
Message-ID: 8c9acaa.1f453.14c0da0402f.Coremail.chjischj@163.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

In my test(PG9.3.4), i found when update a parent table which has a large number of child tables, the execute plan will consume lots of memory. And possibly cause OOM.

For example:
create table maintb(id int,name char(10));
create table childtb_1 (CHECK ( id BETWEEN 1 AND 200)) inherits(maintb);
create table childtb_2 (CHECK ( id BETWEEN 201 AND 400)) inherits(maintb);
...
create table childtb_n ...

When there are 100 child tables,the following update statement will consume about 8MB memory when invoking pg_plan_queries()
update maintb set name = 'aaaaa12345' where id=1;

And, when there are 1000 child tables,the same update statement will consume 717MB memory when invoking pg_plan_queries().

Does this a known problem, and could that be improved in the future?

BTW:
The following comment is according my debuging when update the parent table with 1000 child tables
src/backend/optimizer/plan/planner.c
static Plan *
inheritance_planner(PlannerInfo *root)
{
...
foreach(lc, root->append_rel_list)//### loop 1001 time
{
...
subroot.parse = (Query *)
adjust_appendrel_attrs(root,
(Node *) parse,
appinfo);//### allocate about 300KB memory a time.

...
subroot.append_rel_list = (List *) copyObject(root->append_rel_list);//### allocate about 400KB memory a time.

...
}
...
}

Best Regards
Chen Huajun

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeevan Chalke 2015-03-12 11:06:29 Re: How about to have relnamespace and relrole?
Previous Message Amit Langote 2015-03-12 10:52:25 Re: Parallel Seq Scan