且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Redshift UPDATE 非常慢

更新时间:2023-02-25 19:23:43

你没有提到你正在更新的表的百分比,但重要的是要注意 Redshift 中的 UPDATE 是两步流程:

You didn't mention what percentage of the table you're updating but it's important to note that an UPDATE in Redshift is a 2 step process:

  1. 必须首先将要更改的每一行标记为删除
  2. 然后必须为表中的每一列写入新版本的数据

如果您有大量列和/或正在更新大量行,那么这个过程对于数据库来说可能是非常耗费人力的.

If you have a large number of columns and/or are updating a large number of rows then this process can be very labor intensive for the database.

您可以尝试使用 CREATE TABLE AS 语句来创建表的新更新"版本,然后删除现有表并重命名新表.这还有一个额外的好处,那就是为您留下一个完全排序的表格.

You could experiment with using a CREATE TABLE AS statement to create a new "updated" version of the table and then dropping the existing table and renaming the new table. This has the added benefit of leaving you with a fully sorted table.