integer primary/foreign key vs. varchar(255) primary/foreign key

Hello.

Is there any principal performance (or some other) difference between using
the integer primary/foreign key and using the string (varchar(255)) keys in
queries that use tables joins?

Server is Sybase SQL Anywhere 5.5.04


0
Alexey
2/3/1999 3:26:12 PM
sybase.sqlanywhere.general 32637 articles. 4 followers. Follow

2 Replies
686 Views

Similar Articles

[PageSpeed] 43

Yes!  The primary key will only be made up of 12 bytes.  By using an 
integer you ensure that your entire column is in the key.
-- 
Jim Egan [TeamPS]
Dynamic Data Solutions, Inc. http://www.dyn-data.com
Houston, TX

                ***********************************************************
                          Enterprise Applications in Your Future?
                      JumpStart '99 Enterprise Solutions Conference
                                http://www.JumpStart99.com
                ***********************************************************

0
jegan
2/3/1999 6:48:08 PM
>Yes!  The primary key will only be made up of 12 bytes.  By using an
>integer you ensure that your entire column is in the key.


I've faced one problem with integer foreign key. I want to sort the results
of a query by two fields, one of them is the foreign key. If I use integer
foreign key and if I want to order the results by it, the order of key
values (integers) must coincide with the order of string values. And if I
have to insert some items into the table? In this case I'll have to update
the primary key and of course all foreign keys that reference my table.
There wouldn't be such problem if I use string primary/foreign key (for
example, if I use a string title as a primary key, not some integer
titleid).

(sorting the query results by two fields from different tables is slow)




0
Alexey
2/3/1999 8:27:48 PM
Reply: