Are MySQL Multi-column master keys an optimization issue?

Studying the use of primary keys with multiple columns, and since performance is extremely important with the size of the traffic and the database, I need to know if there is anything to consider before I start throwing away a unique ID method on many of my tables and start using primary keys mulit column.

So, what are the advantages / disadvantages of performance / optimization for using the primary keys of multiple columns compared to the base single column, the auto-inc primary key?

+3
source share
2 answers

I would not have thought that there would be performance issues with multiple primary keys. This is more or less equivalent to having multiple indexes (when inserting, you spend a little more time calculating the index values).

Sometimes a data model makes more sense with multiple keys. I would take care to be the first and worry about performance secondly. You can always add more indexes, improve your queries or change server settings.

I think that most of all I came across a 4-column primary key. Makes me cringe a little, but it worked & sup1 ;.


[1] “worked” is defined as “an application executed for specification” and does not imply that actual tasks were performed using the application. :)

0

- , / ( ) ?

Natural Keys . , , .

, , , , MySQL, - .

, , , . , - .

HTH -

+2

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


All Articles