What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

It looks like there might be a bug in the way the number of tagged questions are calculated. If you look at a question (say, this one) and look at the number of questions tagged Perl, at this writing it says that there are 2889. However, if you click on the tag, it states that there are 2,891. Where did the two come from (or rather, where did they go?)

Edit:

I followed up with Hellbog's suggestion, and decided to post a new question tagged 'perl' on SO. At that point, the number of tags displayed on that question increased to 2890. Refreshing the "tags" page, the number of 'questions tagged' there now stands at 2892. So, if it was a recalculation of different tables, it seems to have properly incremented on both. However, it seems silly to me to store that information in two places, and calculate it two times dynamically, as a new tag is added.

Could it be something else - perhaps the queries to calculate the numbers of tags are slightly different on the two pages?

Edit 2:

Ok, cool. I'll swap this possible-bug. Before I do that, the list of bugs on the sidebar of this page and of the tag page at 817...

Edit 3:

...and after, 'bug' sits at 817 on the sidebar and 816 on the search (one less on search, instead of more). Meanwhile, possible-bug lists as 67 on the sidebar, but 68 on the search. Ok, cool! Now I understand: on adding or removing tags during an edit, the 'tag count' doesn't change.

So, if that count can change when submitting a question, but doesn't change during the edit, is that still considered a bug?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

The SO database is rather denormalized: the number of questions for a given tag is stored alongside the tag in the database somewhere and is recalculated by a scheduled job rather than being recalculated every time the tag count is accessed.

But when you get search results, you get the actual number of tags (since that's part of the search anyway it doesn't cost extra to calculate the count on the fly).

So wait some time and the numbers will converge.

Now, you might want to ask, "Why aren't the tag counts updated when someone clicks on a tag since the count has to be recalculated anyway?" The answer to that is probably because the search functionality is decoupled from the tagging functionality (at least, I'd hope they're decoupled) and it's not really worth the coupling to make one component update the other.

EDIT in response to OP's edit:

Adding new questions updates both because adding the question increments the tag's counter, and searching is always correct.

Retagging a question does not update the tag's counter. If you had a question tagged "perl", then removed that tag, the number of "perl" questions will be inconsistent until the scheduled recalc.

EDIT in response to further edit:

I'd say it's a bug, yeah. It's at least unexpected behaviour, which is at least a usability breakdown.

share|improve this answer
    
It's a bug, but a rather minor one that offloads the database. Furthermore, user interfaces should hurt the user. –  perbert Nov 15 '09 at 15:21
    
What? No, I haven used Lotus Notes stackoverflow.com/questions/238177/worst-ui-youve-ever-used/… –  perbert Nov 15 '09 at 15:24

You must log in to answer this question.

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