string or Guid?

  • Thread starter Thread starter Jeffry van de Vuurst
  • Start date Start date
J

Jeffry van de Vuurst

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
 
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
 
Ok, thanks for the info. I guess I'll stick with Guids.

Jeffry
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top