BUG #16302: too many range table entries - when count partition table(65538 childs) - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16302: too many range table entries - when count partition table(65538 childs)
Date
Msg-id 16302-e45634e2c0e34e97@postgresql.org
Whole thread Raw
Responses Re: BUG #16302: too many range table entries - when count partition table(65538 childs)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16302
Logged by:          Zhou Digoal
Email address:      digoal@126.com
PostgreSQL version: 12.2
Operating system:   CentOS 7.7 x64
Description:

hi,
  when i count a partition table with many childs , it's error below:

```
postgres=> select count(*) from p;
ERROR:  54000: too many range table entries
LOCATION:  add_rte_to_flat_rtable, setrefs.c:425
```

regenerate:

```
do language plpgsql $$   
declare  
begin  
drop table if exists p;  
create table p (id int , info text, crt_time timestamp) partition by range
(crt_time);    
create table p2020 partition of p FOR VALUES FROM ('2020-01-01') TO
('2021-01-01') partition by hash (id);    
create table p2021 partition of p FOR VALUES FROM ('2021-01-01') TO
('2022-01-01') partition by hash (id);    
for i in 0..30000 loop  
  execute format ('create table p2020_%s partition of p2020 FOR VALUES WITH
(MODULUS 65537, REMAINDER %s)', i, i);  
  execute format('alter table p2020_%s set (parallel_workers=52)',i);  
end loop;  
end;  
$$;  

do language plpgsql $$   
declare  
begin  
for i in 30001..60000 loop  
  execute format ('create table p2020_%s partition of p2020 FOR VALUES WITH
(MODULUS 65537, REMAINDER %s)', i, i);  
  execute format('alter table p2020_%s set (parallel_workers=52)',i);  
end loop;  
end;  
$$;  

do language plpgsql $$   
declare  
begin  
for i in 60001..65536 loop  
  execute format ('create table p2020_%s partition of p2020 FOR VALUES WITH
(MODULUS 65537, REMAINDER %s)', i, i);  
  execute format('alter table p2020_%s set (parallel_workers=52)',i);  
end loop;  
end;  
$$;  
```

best regards, 
digoal


pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #16301: unable to connect to server
Next
From: Tom Lane
Date:
Subject: Re: BUG #16302: too many range table entries - when count partition table(65538 childs)