如何在PostgreSQL更新时分配多字段函数结果
我正在PostgreSQL中寻找一种优化方法来实现这一点:如何在PostgreSQL更新时分配多字段函数结果,postgresql,sql-update,Postgresql,Sql Update,我正在PostgreSQL中寻找一种优化方法来实现这一点: update table1 set (a,b)=(somecomplexfunction(table1.something),2*somecomplexfunction(table1.something)) where ... 这会计算两次somecomplexfunction(表1.Somex),我想这样做: update table1 set (a,b)=somecomplexvectorfunction(table1.some
update table1
set (a,b)=(somecomplexfunction(table1.something),2*somecomplexfunction(table1.something))
where ...
这会计算两次somecomplexfunction(表1.Somex),我想这样做:
update table1 set (a,b)=somecomplexvectorfunction(table1.something) where ...
但是更新语法不支持多个字段函数。有什么想法吗?当我把“a”翻一番时,“a”不是旧的“a”吗?
update table1
set
a = somecomplexfunction(table1.something),
b = a * 2
where ...