Kir*_*ach 5 sql transactions amazon-web-services amazon-redshift amazon-data-pipeline
在ETL期间,我们执行以下操作:
begin transaction;
drop table if exists target_tmp;
create table target_tmp like target;
insert into target_tmp select * from source_a inner join source_b on ...;
analyze table target_tmp;
drop table target;
alter table target_tmp rename to target;
commit;
Run Code Online (Sandbox Code Playgroud)
如果这很重要,则由AWS Data Pipeline执行SQL命令。
但是,管道有时会失败,并显示以下错误:
ERROR: table 111566 dropped by concurrent transaction
Run Code Online (Sandbox Code Playgroud)
Redshift支持可序列化的隔离。这些命令之一会中断隔离吗?
是的,这可行,但如果生成临时表需要一段时间,您可能会在运行时看到其他查询的错误。您可以尝试在单独的事务中生成临时表(除非您担心源表的更新,否则可能不需要事务)。然后快速轮换表名,从而减少争用时间:
-- generate target_tmp first then
begin;
alter table target rename to target_old;
alter table target_tmp rename to target;
commit;
drop table target_old;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1970 次 |
| 最近记录: |