我有一个lambda代码,它通过redshift数据api同时向同一个表发出一些插入查询。
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允许并发插入。
发布于 2021-12-14 11:20:27
根据注释中的讨论,可以得出结论,在Redshift中,并发插入在本质上是阻塞的,而不是postgres。请参阅文档:- example.html
编辑:-
如果您正在考虑在上述文档中查找的确切信息,我将直接粘贴到下面:-
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.发布于 2021-12-13 17:42:46
Redshift和Postgres美国MVCC-控制-因此,他们很可能会同样工作。当看到提交时,没有写锁,只有通过提交队列的串行进程。我在Redshift中没有看到这方面的功能问题,所以您应该很好。
从功能上来说,这是很好的,但是Redshift是柱状的,Postgres是基于行的。这导致更新方面的差异。由于这些插入可能只添加了少量行(对于Redshift),而且Redshift上的最小写入大小为每条条列1MB,因此这些块中可能会有大量未使用的空间。如果经常这样做,桌子上就会有大量的浪费空间,需要大量的真空。如果可以的话,您将希望查看这个写入模式,看看是否可以完成更多的插入数据批处理。
https://stackoverflow.com/questions/70335977
复制相似问题