应该索引多对多表吗?什么样的索引最好?
这是一个示例表:
CREATE TABLE user_role (
userId INT,
roleId INT
)
--edit: drachenstern - I added the table def based on the original comments, and assumed ints.
Run Code Online (Sandbox Code Playgroud)
您不需要代理键(除非您使用脑残 ORM)并且您几乎总是需要第二个索引