A JOIN
, even on a PRIMARY KEY
, requires several times as much time as a sequential scan.
Of course it's better to see the table, but my educated guess is that keeping them together will be better.
If the columns you want to split are small and have high cardinality (lots of distinct values), then leave them in the table.
However, if what you do is normalizing (as opposed to mere table split), then normalized design can be faster.
For instance, if your data looks like this:
id value
1 Really really long value 1
2 Really really long value 1
3 Really really long value 1
…
1000 Really really long value 2
1001 Really really long value 2
1002 Really really long value 2
…
, it takes long to scan this table, since the values are large.
Normalizing the table will give the following:
id value
1 1
2 1
3 1
…
1000 2
1001 2
1002 2
…
val_id value
1 Really really long value 1
2 Really really long value 1
Scanning rows of 4
-byte integers is much faster than thousand-byte VARCHAR
's, and the query on the second design will complete faster even despite the extra JOIN
.