HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Is it better to have large tables or many tables (MySQL)

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
tablesbettermysqllargemanyhave

Problem

In terms of performance, is it advisable to have only a few tables with a lot of rows or a lot of tables with only a few rows? In my instance, I have groups that I am keeping data separately for. Is it better to create a new table for every group or keep all the information for the groups in one table (that will get very, very large) and have a column that identifies which group it belongs to? Which version would be better in terms of scalability? I am using PHP to access the data and I only need to get data for one or two groups per page load. I am mainly concerned with the speed of the system when there is a lot of data being stored. Thanks.

Solution

You should ask youself whether those seperate groups are going to need the same table structure. In a relational database, seperate tables should represent seperate entities. Having your database structured this way keeps entities with like fields structured together and creates a logical flow in a database.

As much as possible, try to structure your database so that seperate entities have their own tables. Even if this were to somehow cost some neglegable extra performance, it would save you hours upon hours when writing queries or trying to expand the database.

Trust me, as someone who has worked with databases where tables contain information that logically should exist as five or six tables, you will be saving yourself a lot of headache..

Context

StackExchange Database Administrators Q#147147, answer score: 3

Revisions (0)

No revisions yet.