I work with a partition table (200 partitions), in each partition of 5.000.000 records (table with id sequence, index on every partition and total 10 column, 7 int and 3 text).
I start 200 sessions through java at the same time and try to make the following request:
create or replace procedure create_temp_users(thread integer) language plpgsql as $$
begin
execute format('create temp table temp_users as
select * from users_partition_%s sj', thread);
end $$;
And I get light, but long locks
LWLock BufferMapping create_temp_users(0)
LWLock BufferMapping create_temp_users(1)
LWLock BufferMapping create_temp_users(2)
LWLock BufferMapping create_temp_users(3)
LWLock BufferMapping create_temp_users(4)
...
server spec:
CPU(s): 176
Model name: Intel(R) Xeon(R) Gold 6238 CPU @ 2.10GHz
MemTotal: 2113275652 kB
postgres params:
maintenance_work_mem 100GB
max_parallel_maintenance_workers 80
max_parallel_workers 160
max_parallel_workers_per_gather 80
segment_size 1GB
work_mem 32MB
shared_buffers 496GB
server_version 13.6
server_version_num 130006
Server without replica. How to remove or reduce light locks? I tried to increase work_mem, temp_buffers, remove index. I tried analyze and even copy data from one temp table to another, nothing helps :(