Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

What happens when we vote?

  1. Assert that user is not author of post on which he/she is voting
  2. Delete existing vote (in case when we upvote, then downvote)
  3. Vote (insert a vote record)
  4. (decrement/)increment score of post on which voting is done
  5. #4 requires to grab the weight of vote from vote_type table

Am I wrong or does it really take 5 queries to vote on SO?

share|improve this question
There's even more stuff that goes into that, I'm sure. What if the voter is out of votes? Also, all the complicated rep stuff (if it's a downvote, both users lose rep. If it's an upvote, the post owner might be rep-capped, the post might be CW, etc). And there's rate-limiting that comes into play when you vote too quickly. – jadarnel27 Feb 4 '13 at 14:11
i am sure so team is enough smart(or we can say expert ) to do in very less query at least less than 5 – NullPoiиteя Feb 4 '13 at 14:15
@jadarnel27 yes, you are right, so I was just wondering - one click makes so many queries... – Acute Feb 4 '13 at 15:55
@NullPointer sure, they are experts, but I think there are many queries anyway – Acute Feb 4 '13 at 15:55
If you would like a less-rigorous example, you could explore the OSQA software since it replicates a lot of the SE stuff. That should give you some idea. – jcolebrand Feb 4 '13 at 17:16
It might take more. So what? – Shog9 Feb 4 '13 at 17:26
@Shog9 Nothing. I was doing voting system in my project and was curious if other implementations also have many stuff behind one click. – Acute Feb 4 '13 at 17:32
Well, there'll be as much "stuff" as is needed to fulfill the requirements. SO tends to have a lot of stuff going on, so there'll be checks that have to be made, and values updated (although I don't believe the value of the vote has to be queried for each vote, since that's consistent). – Shog9 Feb 4 '13 at 17:36
Re-opened because, while I don't think this is a particularly useful question, "not constructive" is utterly bogus. I could kinda see "Off topic" if I squint a bit. – Shog9 Feb 4 '13 at 20:51
Hey, let's be fair, I voted to close as too localized. – jcolebrand Feb 4 '13 at 21:33
This was a question about SO, and there was an answer answering that question. That's it. – Acute Feb 5 '13 at 5:35
up vote 10 down vote accepted

It depends. On the scenario, and on how you measure it.

There are a few different behaviors attached to voting on SO: reputation gained or lost for the voter and votee, privileges gained/lost, friendly reminders about commenting or voting on questions more often... Restrictions on when, where, and who can vote... Real-time notifications for both post score and reputation changes...

And then there are things that don't happen right away, but are handled later on as-needed: cleanup for votes that shouldn't have been allowed but were, for fraudulent votes, etc... Recalculation of reputation when that gets out of sync with the actual voting... Badge awards...

I just up-voted this question. According to MiniProfiler, that resulted in something like 17 queries (most fairly trivial).

share|improve this answer
Thanks for detailed answer, can't up vote - not enough reputation yet! 17 queries. – Acute Feb 4 '13 at 18:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .