Answer the question
In order to leave comments, you need to log in
Will performance benefit from such optimization?
There is a reference table:
id (PK), type, some_value, name_russian, name_english, name_italian, name_greek, ...
the data will almost never change.
There is a data table:
id (PK), id_names, other_field
where id_names is the id of the first table.
It is very common to choose an inner join from these two tables, but only type and some_value.
Does it make sense to split the first table into two:
id (PK), type, some_value
id (PK), name_russian, name_english, name_italian, name_greek, ...
to speed up the selection?
Answer the question
In order to leave comments, you need to log in
In the spherical case, there will be a gain.
Is it worth it?
Here the answer lies in the last word of the question - optimization.
One of the rules of optimization says - do not optimize what does not need to be optimized.
Well, or "premature optimization is evil."
Are you experiencing performance issues? Are these problems related to the database? With these requests?
How did you know about it?
If you cannot answer these questions positively, then the optimization is premature; the process of optimization itself and the difficulties associated with it will be worse than the gain from optimization when it is not needed yet.
One more rule smoothly follows from the last question - how did you know that this is a bottleneck? Did you run any tests? Did you use a profiler? Well, any optimization is always tested in practice. Measure the load, change the circuit, measure again. The experiment will take less time than waiting for an answer here. And most importantly, the answer on Habré does not save you from checking it later. This is reasonable only if you have already made sure that you still need optimization ...
PYSY: don't take it for rudeness. I just thought you didn't quite understand what you were asking. I'd be happy to be wrong...
No, such a division of the gain will not bring. You first make a choice and table2 then, using the received set of id_names, make a choice from table1, and there the selection occurs by PK - which is always indexed and the speed will not depend much on the size of the table. So the removal of "unnecessary" fields will not add much speed to you.
If the table2 is large and you often use the condition where type = 2 and some_value > 10, then you can create an index on these 2 fields and everything will work faster.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question