Q:

mysql query speed

I just want to ask which out of the two ways of storing data would give my better results
A. Storing data in a single table with over 20+ columns
OR 
B. Distributing the data into two tables of 15 and 6 columns each
one more thing, even if I distribute the data I still might have to access both the tables at the same time in 60% of cases...
So, which is the best bet out of the two...
Thanks

A:

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.

