﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Edward commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Okay clear, thanks.</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment19</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment19</guid><pubDate>Fri, 02 Nov 2012 13:29:28 GMT</pubDate></item><item><title>Ayende Rahien commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Edward,
You set it up, and you need to ensure that is is unique per all servers</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment18</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment18</guid><pubDate>Thu, 01 Nov 2012 15:52:57 GMT</pubDate></item><item><title>Edward commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Sounds solid. How is that serverprefix calculated/determined?  is it unique? stays it unique?</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment17</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment17</guid><pubDate>Thu, 01 Nov 2012 15:40:41 GMT</pubDate></item><item><title>Ayende Rahien commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Edward,
Okay, in that scenario, what you want to do is to make sure that you are using Raven/ServerPrefix, which will make sure that each of them has its own prefix for the docs.
That would mean that you won't have conflicts when creating new ids.</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment16</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment16</guid><pubDate>Thu, 01 Nov 2012 08:01:56 GMT</pubDate></item><item><title>Edward commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>@Ayende, about replication:

3 servers, master-master scenario. They all have the same data (no partioning although it could be possible) and changes are happening on every server.

1 server at the office with an internet connection which can disconnect, The software at the office is connected to this database.

1 server in the field with an internet connection which can disconnect, The software at this location is connected to this database.

1 server in the cloud for consumers and also office employees.

These servers are replicating each other.  When a connection is reconnected the servers are syncing each other.

It is like MS SQL merge replication: http://msdn.microsoft.com/en-us/library/ms152746(v=sql.105).aspx 


















</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment15</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment15</guid><pubDate>Wed, 31 Oct 2012 17:32:02 GMT</pubDate></item><item><title>Ayende Rahien commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Frank,
This is not serialized, but the calls are transitionally safe.</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment14</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment14</guid><pubDate>Wed, 31 Oct 2012 13:17:57 GMT</pubDate></item><item><title>Ayende Rahien commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Edward,
The scenario we had for that is that we had millions of docs already there, we want to get high ASAP.
We have ids with seven digits, and this code does NOT generate holes.</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment13</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment13</guid><pubDate>Wed, 31 Oct 2012 13:17:17 GMT</pubDate></item><item><title>Ayende Rahien commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Edward,
2 machines, that have a partition among them?
Failover?

There are many scenarios.</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment12</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment12</guid><pubDate>Wed, 31 Oct 2012 13:15:44 GMT</pubDate></item><item><title>Ayende Rahien commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Chris,
That is certainly the way to go about this, sure.</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment11</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment11</guid><pubDate>Wed, 31 Oct 2012 13:14:47 GMT</pubDate></item><item><title>Rafal commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>@dotnetchris
I was thinking about the 'primary key' index in the Esent database. On a second thought, this index is probably sorted in lexicographic order so getting max numeric value could be a problem.</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment9</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment9</guid><pubDate>Tue, 30 Oct 2012 23:18:53 GMT</pubDate></item><item><title>Frank Quednau commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Some kind of nested interval algorithm...I doubt there will be a "hole" . 

Is access to this algorithm serialized?</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment8</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment8</guid><pubDate>Tue, 30 Oct 2012 19:47:37 GMT</pubDate></item><item><title>Edward 3 commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Why  maybeFree = nextIdentityValue*2 ?

Could this not cause huge gaps when ids are like 5 and more digits?


nit picking corner:  
Move line 13 to 7  and remove line 10</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment7</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment7</guid><pubDate>Tue, 30 Oct 2012 17:00:46 GMT</pubDate></item><item><title>dotnetchris commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Rafal, whose to say there's a single index whatsoever? You can use ravendb without a single index ever existing.</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment6</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment6</guid><pubDate>Tue, 30 Oct 2012 16:55:28 GMT</pubDate></item><item><title>Edward commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>When in a disconnected replicated enviroment how does Raven handle unique id's ?

Like: 2 servers, one in the cloud and 1 at the office. 

</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment5</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment5</guid><pubDate>Tue, 30 Oct 2012 16:36:37 GMT</pubDate></item><item><title>Edward commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>This reminds me of the days with MS Access (client database), 

Event OnDuplicateSaveException (key)  

while true
{

  keyAdded=0;
  key++;
  loop ++
  try
  {
    SaveWithNewKey(key)
    break;
  }
  catch
  {
    if (loop &gt; maxKeyAddition)   throw system exception
  }

}




}

</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment4</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment4</guid><pubDate>Tue, 30 Oct 2012 16:34:34 GMT</pubDate></item><item><title>dotnetchris commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Ayende, from some recent discussions on ravendb's forums about generating sequential with no gaps invoice numbers due to government regulations, does this provide an easy solution for that?</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment3</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment3</guid><pubDate>Tue, 30 Oct 2012 14:16:33 GMT</pubDate></item><item><title>Rafal commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>But isn't it possible to retrieve max value from the index?</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment2</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment2</guid><pubDate>Tue, 30 Oct 2012 12:38:42 GMT</pubDate></item><item><title>Jonas H commented on Optimization story: GetNextIdentityValueWithoutOverwritingOnExistingDocuments</title><description>Stop the presses, it's binary search!</description><link>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment1</link><guid>http://ayende.com/159297/optimization-story-getnextidentityvaluewithoutoverwritingonexistingdocuments#comment1</guid><pubDate>Tue, 30 Oct 2012 10:33:44 GMT</pubDate></item></channel></rss>