简体   繁体   中英

Why postgresql use 100% cpu when i put in ANY more then ~15000 parameters

This is my query: select * from dbname where user_name = any(cast(? as text[]))

My conf file:

max_connections = 100
shared_buffers = 1GB
effective_cache_size = 3GB
maintenance_work_mem = 256MB
checkpoint_completion_target = 0.7
wal_buffers = 16MB
default_statistics_target = 100
random_page_cost = 4
effective_io_concurrency = 2
work_mem = 300MB
min_wal_size = 512MB
max_wal_size = 2GB

When i put less then ~15000 all works fine.

Postgresq 9.5.

Not sure if that is possible with Hibernate, but you could try a join instead:

select t.* 
from tablename t 
   join unnest(cast(? as text[])) as x(name) on t.user_name = x.name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM