首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Redshift:对同一表中并发插入的支持

Redshift:对同一表中并发插入的支持
EN

Stack Overflow用户
提问于 2021-12-13 14:08:45
回答 2查看 478关注 0票数 0

我有一个lambda代码,它通过redshift数据api同时向同一个表发出一些插入查询。

代码语言:javascript
复制
1. Insert into Table ( select <some analytical logic> from someTable_1)
2. Insert into Table ( select <some analytical logic> from someTable_2)
3. Insert into Table ( select <some analytical logic> from someTable_n)

考虑到这样的查询将同时触发,Redshift是否为每个插入的表应用了一个锁?还是允许在同一个表中并行插入查询?我这么问是因为postgres允许并发插入。

https://www.postgresql.org/files/developer/concurrency.pdf

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-12-14 11:20:27

根据注释中的讨论,可以得出结论,在Redshift中,并发插入在本质上是阻塞的,而不是postgres。请参阅文档:- example.html

编辑:-

如果您正在考虑在上述文档中查找的确切信息,我将直接粘贴到下面:-

代码语言:javascript
复制
Concurrent COPY operations into the same table
Transaction 1 copies rows into the LISTING table:

begin;
copy listing from ...;
end;
Transaction 2 starts concurrently in a separate session and attempts to copy more rows into the LISTING table. Transaction 2 must wait until transaction 1 releases the write lock on the LISTING table, then it can proceed.

begin;
[waits]
copy listing from ;
end;
The same behavior would occur if one or both transactions contained an INSERT command instead of a COPY command.
票数 0
EN

Stack Overflow用户

发布于 2021-12-13 17:42:46

Redshift和Postgres美国MVCC-控制-因此,他们很可能会同样工作。当看到提交时,没有写锁,只有通过提交队列的串行进程。我在Redshift中没有看到这方面的功能问题,所以您应该很好。

从功能上来说,这是很好的,但是Redshift是柱状的,Postgres是基于行的。这导致更新方面的差异。由于这些插入可能只添加了少量行(对于Redshift),而且Redshift上的最小写入大小为每条条列1MB,因此这些块中可能会有大量未使用的空间。如果经常这样做,桌子上就会有大量的浪费空间,需要大量的真空。如果可以的话,您将希望查看这个写入模式,看看是否可以完成更多的插入数据批处理。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70335977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档