I am calling a function having more than 200 DROP Table Statements using JAVA and I am getting org.postgresql.util.PSQLException: ERROR: out of shared memory. What approach should i follow in order to avoid out of shared memomry ?
PS : Restriction is 开发者_C百科that I can't change any parameters related to PostgresSQL.
If the cause of the error is on the server side: In PostgreSQL a function is always executed inside a transaction. DO
blocks are anonymous functions and are handled the same way. And because even DML commands like CREATE
or DROP
are transactional in PostgreSQL, these commands also stress the usual resources used for ROLLBACK
and COMMIT
.
My guess is that dropping a huge number of large tables eats to much memory. So if you don't need transactional behaviour in your function, the easiest way is to split the large function into several smaller ones. Call each function in a separate transaction.
精彩评论