Originally posted by slimdave
I bet it would be a real challenge to find any difference in performance inserting into a table with a varchar2 pk compared to char, number or date.
Slimdave:
It does matter, if we think logically searching a character would result slower than seraching number. One Character will use 8 bits to be stored on harddisk and number would use 4 bits.
During insert or update oracle has to first search if the string exists in that column so goes if the column is as number & obivously searching a number is much faster than searching a string...
consider a example..
Code:
SQL> create table test1 ( Emp_Name Varchar(8) primary key );
Table created.
Elapsed: 00:00:03.08
SQL> create table test2 ( Emp_Number Number(8) primary key );
Table created.
Elapsed: 00:00:00.01
-- Added some 20 distinct records of 8 charactered value in table test1 & 8 digited value in test2......
SQL> update test1 set emp_name='AbhaySK1' where emp_name='AbhaySK2';
update test1 set emp_name='AbhaySK1' where emp_name='AbhaySK2'
*
ERROR at line 1:
ORA-00001: unique constraint (ABHAY.SYS_C001262) violated
Elapsed: 00:00:00.03
SQL> update test2 set emp_number = 44444444 where emp_number = 22222222;
update test2 set emp_number = 44444444 where emp_number = 22222222
*
ERROR at line 1:
ORA-00001: unique constraint (ABHAY.SYS_C001263) violated
Elapsed: 00:00:00.00
-- Searching a number will be faster then Characters & thas obivious.
it might appear that difference of .03 secs is not a big deal...yes it is not coz u have jus some 20 records so is fast......had u had some 10 million records then this would have gone in may be mins.....
There are plenty of other issues to think about in database design -- forget about this one, it's a irrelevance.
It wud be of importance if he were to have huge tables with crores of records....
Abhay.
funky...
"I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."
"Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"