Performance - string ID vs int ID

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Performance - string ID vs int ID

Post by Ree »

Right now I am developing a PHP app which is going to use the data of users and user groups stored in Active Directory server. I have decided to refer and identify users and user groups in AD using "objectGUID" property. Since the same users are going to have their entries (as well as any app-specific data assigned to them) stored in my app's db, I was wondering if there would be a noticeable performance hit if I used base64 encoded "objectGUID"s as IDs instead of the usual integers? Obviously, in this case any ID based relations stored in other db tables would have to store base64 strings. Since objectGUID is already an object ID in Active Directory, I am a bit reluctant to add additional integer IDs in my app's db since objectGUID is guaranteed to be unique, however, if the performance may suffer noticeably, I would change my mind. Btw, base64 encoded objectGUIDs I think are no less than ~20 chars.

Btw, I am going to use SQL Server 2000 db for my app.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If it's an actual GUID (128-bit number) using the binary form is likely most efficient. Whether it's visually appealling or not is debatable, but that doesn't matter. No one is supposed to see it except the application. If you need to output it, I would give out the string version:

Code: Select all

{4B0FC485-E467-4e0b-A66D-8D52FABC9B5D}
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

Is objectGUID actually something 'which nobody should ever see'? I was thinking about passing it in a query string like this: user-details.php?user={base64_encoded_objectGUID} and then decode the param to get the raw objectGUID and use it to query AD.

I guess storing objectGUIDs as binaries is a good idea. However, when comparing strings and integers... the latter is better as a record ID, correct? If so, is the difference actually noticeable?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

However, when comparing strings and integers... the latter is better as a record ID, correct?
It's pretty simple to compare both, so some testing may be in order. The string form will use slightly more memory often.
Post Reply