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 215455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:28:19+00:00 2026-05-11T18:28:19+00:00

I’m curious about what be the best way to model this for optimized performance…

  • 0

I’m curious about what be the best way to model this for optimized performance… not as concerned about real time data integrity

I’ll continue with the stackoverflow example

Question
  id
  title
Votes
  id
  user
  question

A question has many votes

For many queries however, we’re only concerned with the aggregate number of votes (e.g. to show next to the question).

Good relational db theory would create the two entities (Q and V) as separate relations, requiring a join then a sum or count aggregate call.

Another possibility is to break normal form and occasionally materialize the aggregate value of votes as an attribute in Question (e.g. Question.votes). Performance is gained on reads, however, depending on how stale you are willing to let your “votes” data get, it requires a lot more rights to that Question record… in turn hindering performance.

Other techniques involving caching, etc. can be used. But I’m just wondering, performance wise what’s the best solution? Let’s say the site is higher traffic and receiving a considerable more amount of votes than questions.

Open to non-relational models as well.

  • 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-11T18:28:19+00:00Added an answer on May 11, 2026 at 6:28 pm

    It’s unlikely that a join will be too slow in this case, especially if you have an index on (question) in the Votes table.

    If it is REALLY too slow, you can cache the vote count in the Question table:

     id - title - votecount
    

    You can update the votecount whenever you record a vote. For example, from a stored procedure or directly from your application code.

    Those updates are tricky, but since you’re not that worried about consistency, I guess it’s ok if the vote is sometimes not exactly right. To fix any errors, you can periodically regenerate all cached counts like:

     UPDATE q
     SET votecount = count(v.question)
     FROM questions q
     LEFT JOIN votes v on v.question = q.id
    

    The aggregate count(v.question) returns 0 if no question was found, as opposed to count(*), which would return 1.

    If locks are an issue, consider using “with (nolock)” or “set transaction isolation level read uncommited” to bypass locks (again, based on data integrity being a low priority.)

    As an alternative to nolock, consider “read committed snapshot”, which is meant for databases with heavy read and less write activity. You can turn it on with:

    ALTER DATABASE YourDb SET READ_COMMITTED_SNAPSHOT ON;
    

    It is available for SQL Server 2005 and higher. This is how Oracle works by default, and it’s what stackoverflow itself uses. There’s even a coding horror blog entry about it.

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

Sidebar

Ask A Question

Stats

  • Questions 281k
  • Answers 281k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Not sure of your application, but if this is server-based… May 13, 2026 at 3:53 pm
  • Editorial Team
    Editorial Team added an answer If your value is within a DataList, you can still… May 13, 2026 at 3:53 pm
  • Editorial Team
    Editorial Team added an answer My problem is that I want it to force the… May 13, 2026 at 3:53 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I've got a string that has curly quotes in it. I'd like to replace
In order to apply a triggered animation to all ToolTip s in my app,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.