473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

string or Guid?

Hi,

I'm working with Guids as the primary key of some of my tables. In my code,
I'm working with those Guids. Now I was wondering what is the best way to
work with Guids (in terms of performance, memory usage, etc)? Should I use
the datatype Guid or should I convert them to strings and then just work
with the string representation?

The majority of the processing I do with these Guids is comparing a Guid
with another Guid. Right now, I use the Guid datatype and I pass Guids as
parameters to functions, but maybe it's better to use strings.

Any ideas?

Thanks,
Jeffry
Nov 15 '05 #1
3 13096
Well, as far as perf, a GUID is a 16-byte structure. If you represent it as
a string, then it'll use more memory (each byte will become 2 characters,
and each character is 2 bytes) -- 4 times more.

-mike
MVP

"Jeffry van de Vuurst" <reply.to@newsgroup> wrote in message
news:ea*************@TK2MSFTNGP10.phx.gbl...
Hi,

I'm working with Guids as the primary key of some of my tables. In my code, I'm working with those Guids. Now I was wondering what is the best way to
work with Guids (in terms of performance, memory usage, etc)? Should I use
the datatype Guid or should I convert them to strings and then just work
with the string representation?

The majority of the processing I do with these Guids is comparing a Guid
with another Guid. Right now, I use the Guid datatype and I pass Guids as
parameters to functions, but maybe it's better to use strings.

Any ideas?

Thanks,
Jeffry

Nov 15 '05 #2
Ok, thanks for the info. I guess I'll stick with Guids.

Jeffry
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:#t*************@TK2MSFTNGP10.phx.gbl...
Well, as far as perf, a GUID is a 16-byte structure. If you represent it as a string, then it'll use more memory (each byte will become 2 characters,
and each character is 2 bytes) -- 4 times more.

-mike
MVP

"Jeffry van de Vuurst" <reply.to@newsgroup> wrote in message
news:ea*************@TK2MSFTNGP10.phx.gbl...
Hi,

I'm working with Guids as the primary key of some of my tables. In my

code,
I'm working with those Guids. Now I was wondering what is the best way to work with Guids (in terms of performance, memory usage, etc)? Should I use the datatype Guid or should I convert them to strings and then just work
with the string representation?

The majority of the processing I do with these Guids is comparing a Guid
with another Guid. Right now, I use the Guid datatype and I pass Guids as parameters to functions, but maybe it's better to use strings.

Any ideas?

Thanks,
Jeffry


Nov 15 '05 #3
You probably want to stick to the GUID class for the previous reason stated,
and also, you will probably be working with the SQL uniqueidentifier
data-type. A GUID->uniqueidentifier is a pretty simple cast, opposed to
casting a string back to a GUID, then casting again to a uniqueidentifier.
"Jeffry van de Vuurst" <reply.to@newsgroup> wrote in message
news:uF**************@tk2msftngp13.phx.gbl...
Ok, thanks for the info. I guess I'll stick with Guids.

Jeffry
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:#t*************@TK2MSFTNGP10.phx.gbl...
Well, as far as perf, a GUID is a 16-byte structure. If you represent it
as
a string, then it'll use more memory (each byte will become 2 characters, and each character is 2 bytes) -- 4 times more.

-mike
MVP

"Jeffry van de Vuurst" <reply.to@newsgroup> wrote in message
news:ea*************@TK2MSFTNGP10.phx.gbl...
Hi,

I'm working with Guids as the primary key of some of my tables. In my

code,
I'm working with those Guids. Now I was wondering what is the best way

to work with Guids (in terms of performance, memory usage, etc)? Should I use the datatype Guid or should I convert them to strings and then just work with the string representation?

The majority of the processing I do with these Guids is comparing a Guid with another Guid. Right now, I use the Guid datatype and I pass Guids as parameters to functions, but maybe it's better to use strings.

Any ideas?

Thanks,
Jeffry



Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ME | last post by:
I am developing a kind of plugin framework that I can use for several applications I want to make. In order to identify individual plugins I am currently doing something like the code below...
3
by: James DeClerk | last post by:
Hi everyone. I have a guid that's in string format. I would like to convert it to a GUID. I'm doing this on the unix platform, so it will apply to only to GCC/G++. #include "stdafx.h"...
1
by: Jeffrey B. Holtz | last post by:
I'm trying to get the Name of the USB device pluged in from the RegisterDeviceNotification that I've used P/Invoke to marshal. I have seen a similar posting on the VisualBasic newgroups but I do...
1
by: Arjen | last post by:
Hi, I have a Guid value. I want to save this inside the memory. What is the best way: save it as a Guid? Or as string? Thanks!
3
by: Eagle | last post by:
How do I convert a Guid to a string? I am trying to retrieve a value from a dataview into a string variable: CurrentValue = drv(strColumn) and it works fine until the strColumn is a guid...
10
by: Crirus | last post by:
Is there a function that return some random ID like string alphanumeric? Like this: A35sDsd1dSGsH Thanks Crirus
1
by: Wolf | last post by:
Hi I am trying to set a property(PartyHomeAddressID) = to a guid in a ini file. But everytime when the ini file has an empty guid it breaks with an error tellin me a guid is 32 char long with 4...
6
by: SevDer | last post by:
Is there a way to test guid string? I want to do it without try catch block to save on performance. Thanks in advance. -- SevDer
1
by: Steph | last post by:
hello, i ve tries to convert a generic into a string for use string.join. no problems with arraylist : ArrayList al = new ArrayList(); al.Add("J1"); al.Add("J2"); al.Add("J3");...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.