So if I have an sql query like these:
SELECT title, document FROM docs WHERE id = "1" and type = "2"
SELECT title FROM docs WHERE id = "1"
SELECT title FROM docs WHERE member = "foo"
to maximize speed for the first one i. would I have to index only the keys (id and type together? seperate?) ii. would I also have to index title an开发者_如何学编程d document (together,separate)
same type of questions apply for the second one, and for the third query i. would I have to index only member? IM just trying to understand mysql retrieval and indexing.
You need 2 indexes
(id, type, title)
(member, title)
id, type
makesid
redundant- adding title makes the index covering
1) Index both id and type together, but not title and document
2) Index id only
3) index member only
in other word you have to index {id}, {id, type}, {member}
精彩评论