[英]Performance increase for an update statement
我需要使用相同列的修剪版本更新表中的所有列。 表有 130 列和 500 萬條記錄。 查詢運行了 3 個多小時,沒有任何完成的跡象。
Begin
UPDATE table
SET column = TRIM(column)
WHERE date = '01-01-21';
.
..
..
Commit;
End;
/
請幫助提高此查詢的性能。 PS:沒有一列有任何索引。
不要使用 PL/SQL 但 SQL:
update that_table set
col1 = trim(col1),
col2 = trim(col2),
...
col130 = trim(col130)
where date_column = date '2021-01-01';
where
子句中的列應該 - 可能 - 僅在您對其進行過濾時被索引。 如果要更新整個表,則根本不需要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.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.