sql - Does the number of columns updated affect the performance of update query in Oracle -
i have oracle update query below
query1 : update table1 set col1=value1 tablekey=123
query2 : update table1 set col1=value1,col2=value2 tablekey=123
will there performance difference between these two?
nothing much, except number of bytes.
you check explain plan:
sql> explain plan update emp set ename='a' empno=7369; explained. sql> sql> select * table(dbms_xplan.display); plan_table_output -------------------------------------------------------------------------------- plan hash value: 1494045816 --------------------------------------------------------------------------- | id | operation | name | rows | bytes | cost (%cpu)| time | --------------------------------------------------------------------------- | 0 | update statement | | 1 | 10 | 3 (0)| 00:00:01 | | 1 | update | emp | | | | | |* 2 | table access full| emp | 1 | 10 | 3 (0)| 00:00:01 | --------------------------------------------------------------------------- predicate information (identified operation id): plan_table_output -------------------------------------------------------------------------------- --------------------------------------------------- 2 - filter("empno"=7369) 14 rows selected. sql> sql> explain plan update emp set ename='a', deptno=30 empno=7369; explained. sql> sql> select * table(dbms_xplan.display); plan_table_output -------------------------------------------------------------------------------- plan hash value: 1494045816 --------------------------------------------------------------------------- | id | operation | name | rows | bytes | cost (%cpu)| time | --------------------------------------------------------------------------- | 0 | update statement | | 1 | 13 | 3 (0)| 00:00:01 | | 1 | update | emp | | | | | |* 2 | table access full| emp | 1 | 13 | 3 (0)| 00:00:01 | --------------------------------------------------------------------------- predicate information (identified operation id): plan_table_output -------------------------------------------------------------------------------- --------------------------------------------------- 2 - filter("empno"=7369) 14 rows selected.
for more detailed information, set autotrace on:
sql> set autotrace on sql> update emp set ename='a' empno=7369; 1 row updated. execution plan ---------------------------------------------------------- plan hash value: 1494045816 --------------------------------------------------------------------------- | id | operation | name | rows | bytes | cost (%cpu)| time | --------------------------------------------------------------------------- | 0 | update statement | | 1 | 10 | 3 (0)| 00:00:01 | | 1 | update | emp | | | | | |* 2 | table access full| emp | 1 | 10 | 3 (0)| 00:00:01 | --------------------------------------------------------------------------- predicate information (identified operation id): --------------------------------------------------- 2 - filter("empno"=7369) statistics ---------------------------------------------------------- 4 recursive calls 1 db block gets 3 consistent gets 0 physical reads 352 redo size 857 bytes sent via sql*net client 842 bytes received via sql*net client 3 sql*net roundtrips to/from client 2 sorts (memory) 0 sorts (disk) 1 rows processed sql> update emp set ename='a', deptno=30 empno=7369; 1 row updated. execution plan ---------------------------------------------------------- plan hash value: 1494045816 --------------------------------------------------------------------------- | id | operation | name | rows | bytes | cost (%cpu)| time | --------------------------------------------------------------------------- | 0 | update statement | | 1 | 13 | 3 (0)| 00:00:01 | | 1 | update | emp | | | | | |* 2 | table access full| emp | 1 | 13 | 3 (0)| 00:00:01 | --------------------------------------------------------------------------- predicate information (identified operation id): --------------------------------------------------- 2 - filter("empno"=7369) statistics ---------------------------------------------------------- 4 recursive calls 1 db block gets 3 consistent gets 0 physical reads 316 redo size 858 bytes sent via sql*net client 853 bytes received via sql*net client 3 sql*net roundtrips to/from client 2 sorts (memory) 0 sorts (disk) 1 rows processed sql>
so, see slight difference bytes sent via sql*net client
, bytes received via sql*net client
. more columns, difference increase more.
Comments
Post a Comment