performance - Mysql an index with 8 columns -
We have a table with 1,000,000 records. In this table, there is a key on 8 string columns -
create table "table" ("PK1" variant (20) default faucet, "PK2" Vertical (20) default faucet, Default void, "pk5" varchar (20) default void, "pk6" varchar (20) default zeros, "pk7" varchar (20) default zero, "pk5" varchar (20) default zero, "pk5" varchar (20) Default void, "more_data1" integer (11) default zero, "more_data2" integer (11) default zero, "more_data3" integer (11) default zero, "composite_pk" varchar (200) Default zero, key "MainKey" ("PK1", "pk2", "PK3", "pk4", "pk5", "pk6", "pk7", "pk8"), void zero, "more_data4" integer (11) ) Engine = InnoDB default charset = Ascii Not all columns are filled out, and clearly, in most rows, there are only 3-4 column fields.
To prevent duplication in the table for the same key being used in order to use this key. Because the user can configure that he is okay with repetition because this is not unique / p.
This table has 80% reading, 20% write.
I think the complex address composite index can be unused. Do you think it is better to create a new column? - A combination of all P's columns (filed through a trigger) and this new column will be listed as a varchar (200),
Or just leave it like this?
Thank you!
This is too long for a comment.
If the option is between the index with the eight columns and puts the same data in the same column, leave the index as it is! It is difficult to imagine the questions, where the single-consorted-column index would be useful. The 8-column index can be useful for many queries. Update / run and will be slower than index update / inserts index only.
If you are trying to ensure that the eight columns are a duplicate, then you need NULL value is allowed, so this will not be a problem).
If you want 8 columns to be an overall primary key, then I suggest declaring them to be not tap and all 8 have the primary key. He said to declare in form, he said, I am a fan of the automatically increased integer primary key. If you have used such a primary key, then a unique index will be sufficient on 8 columns.
Comments
Post a Comment