Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8721587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:14:45+00:00 2026-06-13T07:14:45+00:00

I have the following test class that represents a composite _id: private sealed class

  • 0

I have the following test class that represents a composite _id:

private sealed class Id
{
    public int p0 { get; set; }
    public int p1 { get; set; }
    public int p2 { get; set; }
    public int p3 { get; set; }
    public int p4 { get; set; }
    public int p5 { get; set; }
    public int p6 { get; set; }
    public int p7 { get; set; }
}

The data class:

private sealed class MdbData
{
    [BsonId]
    public Id _Id;
    public List<string> data = new List<string>();
}

I wrote an upsert statement that uses all 8 fields, but the speed was horrific. So what I want to do next is use p0, BinarySerialized(p1:p7) as the _id. My use case allows me to concatenate these fields without issue.

What is the best way to serialize p1-p7? C#’s serializer, or BSON’s?

For the record, the upsert:

col.Update(Query.And(
    Query.EQ("_id.p0", doc.p0),
    Query.EQ("_id.p1", doc.p1),
    Query.EQ("_id.p2", doc.p2),
    Query.EQ("_id.p3", doc.p3),
    Query.EQ("_id.p4", doc.p4),
    Query.EQ("_id.p5", doc.p5),
    Query.EQ("_id.p6", doc.p6),
    Query.EQ("_id.p7", doc.p7)),
    Update.Push("data", doc.data),
    UpdateFlags.Upsert);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:14:46+00:00Added an answer on June 13, 2026 at 7:14 am

    I would start by investigating why your upsert was so slow. It might just be the way the query part was written, in which case changing the Id might not help.

    If you do want to encode your p1 through p7 components as binary bytes, I would recommend you define your Id class like this:

    public sealed class Id
    {
        public int p0 { get; set; }
        public byte[] p1to7 { get; set; }
    }
    

    But then you have to write some helper methods or properties somewhere to deal with packing and unpacking the bytes. I wouldn’t use any kind of serializer, but just pack the ints 4 bytes at a time (so p1to7 would be 28 bytes long).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following class to test: public abstract class Challenge { protected int
I have the following code: public class Test extends JFrame implements ActionListener{ private static
I have the following test: @Test(expected=ArithmeticException.class) public void divideByZero() { int n = 2
I have a class... class Document { public int GroupID { get; set; }
I have following code I want to test: public class MessageService { private MessageDAO
I have following test class @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {/services-test-config.xml}) public class MySericeTest { @Autowired
I have following test.pyx cdef public class Foo[object Foo, type FooType]: cdef public char*
I have following code public class TEST { public static void main(String arg[]){ try
I have the following code: class Test { public static void main(String[] args) {
Suppose you have the following class: class Test : ISerializable { public static Test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.