[英]Performance increase for an update statement
I need to update all the columns in a table using the trimmed version of the same columns.我需要使用相同列的修剪版本更新表中的所有列。 Table has 130 columns and 5 million records.表有 130 列和 500 万条记录。 And the query is running more than 3 hours without any sign of completion.查询运行了 3 个多小时,没有任何完成的迹象。
Begin
UPDATE table
SET column = TRIM(column)
WHERE date = '01-01-21';
.
..
..
Commit;
End;
/
Kindly help in improving the performance of this query.请帮助提高此查询的性能。 PS: none of the columns have any index. PS:没有一列有任何索引。
Don't use PL/SQL but SQL:不要使用 PL/SQL 但 SQL:
update that_table set
col1 = trim(col1),
col2 = trim(col2),
...
col130 = trim(col130)
where date_column = date '2021-01-01';
Column in where
clause should - probably - only be indexed as you're filtering on it. where
子句中的列应该 - 可能 - 仅在您对其进行过滤时被索引。 If you're updating the whole table, you don't need where
clause at all.如果要更新整个表,则根本不需要where
子句。
Also, if that column's datatype is date
, then use date literal or to_date
function with appropriate format model, ie don't force Oracle to implicitly convert string (that's '01-01-21'
to date and spend some time doing so. Also, if that column's datatype is date
, then use date literal or to_date
function with appropriate format model, ie don't force Oracle to implicitly convert string (that's '01-01-21'
to date and spend some time doing so.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.