Mysql query speed

I just want to ask which of the two ways to store data will give the best results.

a. Data storage in one table with more than 20 columns

OR

B. Dissemination of data into two tables of 15 and 6 columns each

one more thing, even if I distribute the data, I still have to access both tables simultaneously in 60% of cases ...

So this is the best choice of two ...

thanks

+3
source share
3 answers

A JOIN, even on a PRIMARY KEY, takes several times longer than sequential scanning.

Of course, it is better to see the table, but my educated guess is that keeping them together would be better.

, , ( ), .

, ( ), .

, :

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

, .

:

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

4 -byte , VARCHAR, , JOIN.

+2

, . , A, , . , , , B.

+1

, . , ? , , , . , , , . , .

, , .

I suggest reading how-do-i-ask-for-help-optimizing-fixing-queries-in-mysql in stackoverflow to find out how to call MySQL for help.

+1
source

Source: https://habr.com/ru/post/1714061/


All Articles