Generating own sequential guid

226 views
Skip to first unread message

jgauffin

unread,
Dec 2, 2012, 2:08:03 PM12/2/12
to rav...@googlegroups.com
I need to generate my own primary keys (the persistence comes later). Is it beneficial to generate a sequential GUID as described here: http://www.codeproject.com/Articles/388157/GUIDs-as-fast-primary-keys-under-multiple-database

If yes: Which of the described versions are better for Raven?

.. or should I just keep it simple and use regular GUIDs?

Matt Johnson

unread,
Dec 2, 2012, 4:52:13 PM12/2/12
to ravendb
I asked the same thing back in March and Oren said that it doesn't
matter because Raven does not keep a clustered index by document key.
https://groups.google.com/group/ravendb/browse_thread/thread/6524956af6894b7a/

I've since switched to string ids, but I assume the advice is still
relevant.


On Dec 2, 12:08 pm, jgauffin <jonas.gauf...@gmail.com> wrote:
> I need to generate my own primary keys (the persistence comes later). Is
> it beneficial to generate a sequential GUID as described
> here:http://www.codeproject.com/Articles/388157/GUIDs-as-fast-primary-keys...

Oren Eini (Ayende Rahien)

unread,
Dec 3, 2012, 4:53:49 AM12/3/12
to rav...@googlegroups.com
Avoid using guids in general, you can use RavenDB HiLo directly, if you need to, and it would generate easy to use numerics.

jgauffin

unread,
Dec 3, 2012, 4:57:44 AM12/3/12
to rav...@googlegroups.com
I need to generate the ID at client side in this app. The RavenDB document session doesn't exist yet. 

Oren Eini (Ayende Rahien)

unread,
Dec 3, 2012, 5:13:40 AM12/3/12
to rav...@googlegroups.com
Define client side? in JS ?

Jonas Gauffin

unread,
Dec 3, 2012, 5:17:28 AM12/3/12
to rav...@googlegroups.com
Client/Server. So the client is a .NET app, but RavenDB is not installed/referenced in it.

I could of course create a new request/reply which is only used to generate a new ID if you think that using any kind of GUIDs are a bad idea. In that case I would like to see how I can retrieve a new ID from Raven without creating a new document.

Oren Eini (Ayende Rahien)

unread,
Dec 3, 2012, 5:22:27 AM12/3/12
to rav...@googlegroups.com
Jonas,
Implement your own HiLo logic, then. You request a range, and then you can generate numbers without that range independently

Oren Eini (Ayende Rahien)

unread,
Dec 3, 2012, 5:22:49 AM12/3/12
to rav...@googlegroups.com
Note that my objections to this are based solely on the fact that I don't like guids, it would work & perform well

Kijana Woodard

unread,
Dec 3, 2012, 8:50:27 AM12/3/12
to rav...@googlegroups.com

How about if the id ends up being a string such as "foos/guid"?

I assume your distaste is because they are hard to read/debug/change on the url/etc?

Oren Eini (Ayende Rahien)

unread,
Dec 4, 2012, 2:55:58 AM12/4/12
to rav...@googlegroups.com
Yes, exactly, and foos/guid is still hard to read.
Reply all
Reply to author
Forward
0 new messages