Tell me more ×
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. It's 100% free, no registration required.

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
1  
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
2  
You should not post your questions on multiple sites. This was cross-posted on SO -- stackoverflow.com/questions/12988199/… – 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
show 1 more comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.