Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I collect how people tag topics with categories in table like:

ID | topic_id | votes_Category_1 | votes_Category_2 |.......... | votes_Category_12

This table holds 1 row per topic and dynamically keeps count of votes on each category I dump this table every hour for history reasons. Lets say table contain 2 million rows. dumped every hour in history tables.

This solution is not flexible (that is minor because categories are pretty solid) if I want to add column Category_13, so I'm thinking about this one:

ID | topic_id | Category_id | vote_count

This solution will create 12 rows per topic, its better structured and more flexible but I'll have to dump every hour 24 million rows.

I need the best 10 topics in each category!

  1. case 1: order by votes_Category_x desc limit 10
  2. case 2: where category_id=x order by vote_count desc limit 10

Which one would be better JUST!!! from performance stand point:

  1. To have 2 million rows with 14 columns
  2. To have 24 million rows with 4 columns

Thank you

share|improve this question

closed as too localized by Jack Douglas Jun 15 '13 at 5:22

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

In my view the added flexibility of the second solution far outweighs any possible advantage of the first one. From a dump speed perspective, I suppose it is a function of data size, which won't be very different between the two. – dezso Oct 20 '12 at 15:00
You should not post your questions on multiple sites. This was cross-posted on SO --… – bluefeet Oct 20 '12 at 15:11
Hi i'm new to Stack Overflow and a user there suggested for me to post it here. – ntg Oct 20 '12 at 15:14
The proper way to do that would be asking the moderators over there to migrate it here. – dezso Oct 20 '12 at 15:22
Thank you for being so helpful. I'll do that – ntg Oct 20 '12 at 15:23