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 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

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string

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.