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

  • Home
  • SEARCH
  • 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 7548277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:39:29+00:00 2026-05-30T09:39:29+00:00

I have a scenario to optimise how my web app is storing data in

  • 0

I have a scenario to optimise how my web app is storing data in the session and retrieving it. I should point out that I’m using SQL Server as my session store.

My scenario is I need to store a list of unique IDs mapped to string values in the user’s session for later use. The current code I’ve inherited is using a List<T> with a custom object but I can already see some kind of dictionary is far better for performance.

I’ve tested two ideas for alternatives:

  1. Storing a Dictionary<int, string> in the session. When I need to get the strings back, I get the dictionary from the session once and can test each ID on the dictionary object.

  2. Since the session is basically like a dictionary itself, store the string directly in the session using a unique session key e.g. Session["MyString_<id>"] = stringValue". Getting the value out of the session would basically be the inverse operation.

My test results show the following based on the operation I need to do and using 100 strings:

  • Dictionary – 4552 bytes, 0.1071 seconds to do operation
  • Session Direct – 4441 bytes, 0.0845 seconds to do operation

From these results I see that I save some space in the session (probably because I’ve not got the overhead of serialising a dictionary object) and it seems to be faster when getting the values back from the session, maybe because strings are faster to deserialise than objects.

So my question is, is it better for performance to store lots of smaller objects in session rather than one big one? Is there some disadvantage for storing lots of smaller objects vs. one bigger object that I haven’t seen?

  • 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-05-30T09:39:30+00:00Added an answer on May 30, 2026 at 9:39 am

    There are penalties for serializing and searching large objects (they take up more space and processor time due to the need to represent a more complex structure).

    And why do 2 searches when you can do only one.

    Also, all documentation that deal with caching/storing solutions mention that it is much more efficient to serialize a single value from a list based on a computed key, rather than store all the dictionary and retrieve that and search in it.

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

Sidebar

Related Questions

I have a path defined: when /the admin home\s?page/ /admin/ I have scenario that
I have a scenario where I need to upload a file from one web
I have a scenario where users of my ASP.NET web application submit testimonials consisting
I have this scenario where I need data integrity in the physical database. For
I am currently running a web app that sees several (~15) users logging in
We have a data provider class that returns repositories for each aggregate in our
I have a scenario where I have some text, which should be user-selectable. The
I have scenario, Page contains Check in date and Check out date for input.
I have scenario, I have two update panels on the page (both have update
I have a scenario where I have to check whether user has already opened

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.