EzzDev
EzzDev

Reputation: 10210

Choose between storing all mysql data in 1 table or split data to 2 or more tables

i am creating a news mysql database

info i need to store include

when listing news i dont query the large newscontent field but its in the same table

on large scale where millions of articles is it better to store news content on same table as long as i query only the news title without content when listing or create separate table for listing and another displaying full content ?

thanks

Upvotes: 0

Views: 112

Answers (1)

Jehad Keriaki
Jehad Keriaki

Reputation: 545

While both ways would work fine, there are advantages/disadvantages of each:

  • One large table: As you mentioned, you 'may' read more data than needed (Solution for that later)
  • Two tables: More fields to add, and 'join' will be required when contents are needed, so 'more complexity and slower queries to get contents'

My proposals:

  • If one table, then create index on each of the fields that you want to query, so when you query, the index file will be used (Which is smaller in size that the data file)
  • If one table, partition the table based on some criteria, like date. This way you avoid having to deal with huge table in the future
  • Personally, I would go with two tables solution, and I would partition the tables that has "newscontent". [Although it is more complex from development POV, it is easier on DB servers, and this is more important]

Upvotes: 1

Related Questions