Click here to Skip to main content
14,689,511 members
Home » Discussions » Database
   

Database

 
GeneralRe: Best way to batchprocess a large update Pin
#realJSOP29-May-19 2:20
mva#realJSOP29-May-19 2:20 
GeneralRe: Best way to batchprocess a large update Pin
Jörgen Andersson29-May-19 3:59
professionalJörgen Andersson29-May-19 3:59 
GeneralRe: Best way to batchprocess a large update Pin
#realJSOP29-May-19 6:13
mva#realJSOP29-May-19 6:13 
AnswerRe: Best way to batchprocess a large update Pin
#realJSOP29-May-19 2:14
mva#realJSOP29-May-19 2:14 
GeneralRe: Best way to batchprocess a large update Pin
Jörgen Andersson29-May-19 4:01
professionalJörgen Andersson29-May-19 4:01 
QuestionMongoDB Int Primary Key Pin
Kevin Marois17-May-19 9:41
professionalKevin Marois17-May-19 9:41 
AnswerRe: MongoDB Int Primary Key Pin
jschell18-May-19 8:09
Memberjschell18-May-19 8:09 
GeneralRe: MongoDB Int Primary Key Pin
Kevin Marois20-May-19 7:21
professionalKevin Marois20-May-19 7:21 
jschell wrote:
Because the key is generated on the client not the server.

So what if I created a PK table on the sever:
public int GetNextPrimaryKey(string collectionName)
{
    lock(_lockObj)
    {
        // Get the PrimaryKeys collection from the DB
        IMongoCollection<PrimaryKeyEntity> pkCol = GetCollection<PrimaryKeyEntity>("PrimaryKeys");

        // Attempt to find the row for the collection 
        PrimaryKeyEntity entity = pkCol.Find(x => x.CollectionName == collectionName).FirstOrDefault();

        // If it doesn't exist...
        if (entity == null)
        {
            // Create and insert the row for the desired collection
            entity = new PrimaryKeyEntity
            {
                PrimaryKey = 1,
                CollectionName = collectionName
            };
            pkCol.InsertOne(entity);
        }
        else
        {
            // Increment the PK
            entity.PrimaryKey = entity.PrimaryKey + 1;

            var filter = Builders<PrimaryKeyEntity>.Filter.Eq(x => x.CollectionName, collectionName);
            var update = Builders<PrimaryKeyEntity>.Update.Set(x => x.PrimaryKey, entity.PrimaryKey);
            var result = pkCol.UpdateOneAsync(filter, update).Result;
        }

        return entity.PrimaryKey;
    }
}
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

GeneralRe: MongoDB Int Primary Key Pin
jschell23-May-19 6:33
Memberjschell23-May-19 6:33 
QuestionMySQL Pin
Member 1437004615-May-19 4:07
MemberMember 1437004615-May-19 4:07 
AnswerRe: MySQL Pin
Richard MacCutchan15-May-19 4:12
mveRichard MacCutchan15-May-19 4:12 
GeneralRe: MySQL Pin
Member 1437004615-May-19 21:24
MemberMember 1437004615-May-19 21:24 
GeneralRe: MySQL Pin
Richard MacCutchan15-May-19 22:17
mveRichard MacCutchan15-May-19 22:17 
GeneralRe: MySQL Pin
Member 1437004615-May-19 21:25
MemberMember 1437004615-May-19 21:25 
GeneralRe: MySQL Pin
Richard MacCutchan15-May-19 22:18
mveRichard MacCutchan15-May-19 22:18 
QuestionMySql vs MariaDB Pin
DerekT-P15-May-19 2:25
professionalDerekT-P15-May-19 2:25 
AnswerRe: MySql vs MariaDB Pin
Richard MacCutchan15-May-19 4:15
mveRichard MacCutchan15-May-19 4:15 
AnswerRe: MySql vs MariaDB Pin
jschell18-May-19 8:18
Memberjschell18-May-19 8:18 
GeneralRe: MySql vs MariaDB Pin
DerekT-P19-May-19 8:23
professionalDerekT-P19-May-19 8:23 
GeneralRe: MySql vs MariaDB Pin
jschell23-May-19 6:29
Memberjschell23-May-19 6:29 
GeneralRe: MySql vs MariaDB Pin
DerekT-P23-May-19 9:22
professionalDerekT-P23-May-19 9:22 
GeneralRe: MySql vs MariaDB Pin
jschell2-Jun-19 9:36
Memberjschell2-Jun-19 9:36 
QuestionWhat is an alias? Pin
Shraddha_Patel7-May-19 19:20
MemberShraddha_Patel7-May-19 19:20 
AnswerRe: What is an alias? Pin
Richard MacCutchan7-May-19 22:23
mveRichard MacCutchan7-May-19 22:23 
AnswerRe: What is an alias? Pin
#realJSOP28-May-19 2:52
mva#realJSOP28-May-19 2:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.