473,287 Members | 1,827 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,287 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 13015
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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.