PostgreSQL:如何将大数据集插入表中?

标签 postgresql dataset

我在 PostgreSQL 数据库中有一个表,我需要向其中添加 200 万行。 当我尝试使用 INSERT INTO 查询时,它会抛出

ERROR:  canceling statement due to statement timeout
CONTEXT:  PL/pgSQL function cdb_checkquota() line 11 at IF

我已经尝试重新配置 postgresql.conf 文件(扩大 work_memstatement_timeout)但它没有用。

谁能告诉我我想念这里的是什么? 顺便说一句,我正在使用 INSERT INTO 查询,因为我需要复制表数据,所以我在没有主键的情况下处理表数据,以防止重复键。

最佳答案

据我所知,错误仅在设置 statement_timeout 时触发:

denis=# select pg_sleep(2);
 pg_sleep 
----------
 
(1 row)
denis=# set statement_timeout to 1;
SET
denis=# select pg_sleep(2);
ERROR:  canceling statement due to statement timeout

您是否尝试过完全禁用它?

set statement_timeout to 0

顺便说一句,这应该是默认设置。并根据 docs (强调我的):

statement_timeout (integer) Abort any statement that takes more than the specified number of milliseconds, starting from the time the command arrives at the server from the client. If log_min_error_statement is set to ERROR or lower, the statement that timed out will also be logged. A value of zero (the default) turns this off.

Setting statement_timeout in postgresql.conf is not recommended because it would affect all sessions.

关于PostgreSQL:如何将大数据集插入表中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27401087/

相关文章:

.net - 数据集是否可扩展?像 myspace 这样的网站会使用它们进行数据检索吗?

ruby-on-rails - rails 范围内的时区独立到期日比较

postgresql - 物理恢复 heroku postgresql 数据库

python - 如何使用 SQLAlchemy 选择 PostgreSQL 数组中某个位置的值?

python - Python 中的 datasets.load_iris()

data-structures - 用于基准测试的随机单词大文本文件字典?

algorithm - 我怎样才能将这个不太直线的数据集拟合到直线网格

sql - 如何在 PostgreSQL 中将日期格式设置为 `YYYY-MM-DDTHH24:MI:SS`

postgresql - 如何在 postgresql 查询中从字节中获取一个字节字符?

javascript - 如何将 D3 数据插值/动画函数应用于动态变化的饼图