views:

29

answers:

3

I am working on a game that I am going to open to the public to have on their game. The game stores lots of information (about 300 rows) per website and spends a lot of time updating values within this MySQL database.

Is it better (faster/efficient) to add a new table for every website or to just have 1000's of rows in one table and add a column "website_id" or similar?

+3  A: 

It is better to add more rows in the same table and create an index on the table. An index on the website_id would probably help a lot.

Mark Byers
A: 

Definitely go for rows with a website_id. Definitely index the website_id and it should be much more efficient -- I have about 50-60 sites running on a similar concept and it is blazing fast.

Kerry
A: 

Could you perhaps give us some more information pertaining to the kind of information you're storing and how you are going to manipulate this data?

If a single table is going to have 300+ entries for what should be a single entity, you may have a flaw in your physical database design. Ideally, you want to keep your tables from having too many entries, but this is unavoidable at times.

You might also want to look into partitioning as a means of keeping your tables smaller, if you are going to have as much data as you think.

At a glance though, it appears that using a website_id would make sense. Create a table indexing just these, and all of your additional tables can use a field referencing the website_id where required.

baultista