Second if you still can't make decision install wordpress or other popular cms and check how they do some stuff like indexes.
As I have installed wordpress and checked all the stuff there were I come to conclusion:
Collation:
Collation:
utf8mb4_unicode_ci |
index tip2: if you think you need uniq index and it is only one - make it primary.
Simple many to many relations
article (id, date, text); id primary. Anything else you need to use where, max, group by etc - simple index
article (id, date, text); id primary. Anything else you need to use where, max, group by etc - simple index
tags (id, name, slug), id - primary, name and slug simple index (as we need them a lot we will use them from indexes data and will not need to get data from the disc
article_tags (article_id, tag_id). Primary index on 2 columns (article_id, tag_id) and simple index on tag_id.
Remember when using index on more than 1 column the order is very important. Read more in official docs. But basically if you have index on columns a, b, c you can benefit from index only when searching a, or a + b or a+b+c. If you search on b or c or b+c value it will not use index.
Learn more about this as usually at official docs http://dev.mysql.com/doc/refman/5.7/en/multiple-column-indexes.html
Learn more about this as usually at official docs http://dev.mysql.com/doc/refman/5.7/en/multiple-column-indexes.html
If you don't need -number (for example -12345 with minus sign), on number types make them unsigned
No comments:
Post a Comment