org.postgresql.util。PSQLException:错误:在共享内存中。

时间:2022-05-21 02:00:33

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 ?

我正在调用一个函数,它使用了JAVA和我正在获得org.postgresql.util的200多个DROP Table语句。PSQLException:错误:在共享内存中。我应该遵循什么样的方法才能避免共享内存?

PS : Restriction is that I can't change any parameters related to PostgresSQL.

限制是我不能更改与PostgresSQL相关的任何参数。

1 个解决方案

#1


1  

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.

如果错误的原因是在服务器端:在PostgreSQL中,函数总是在事务中执行。块是匿名函数,它们的处理方式相同。而且,因为即使是像CREATE或DROP这样的DML命令在PostgreSQL中都是事务性的,这些命令也会强调用于回滚和提交的常用资源。

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.

我的猜测是,将大量的大型表丢弃在内存中。因此,如果函数中不需要事务行为,最简单的方法是将大函数分解成几个较小的函数。在单独的事务中调用每个函数。

#1


1  

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.

如果错误的原因是在服务器端:在PostgreSQL中,函数总是在事务中执行。块是匿名函数,它们的处理方式相同。而且,因为即使是像CREATE或DROP这样的DML命令在PostgreSQL中都是事务性的,这些命令也会强调用于回滚和提交的常用资源。

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.

我的猜测是,将大量的大型表丢弃在内存中。因此,如果函数中不需要事务行为,最简单的方法是将大函数分解成几个较小的函数。在单独的事务中调用每个函数。