我是否需要在外键上创建索引? [英] Do I need to create indexes on foreign keys?

查看:132
本文介绍了我是否需要在外键上创建索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张桌子 A 和一张桌子 B A B 上有 B 的外键主键, B_ID

I have a table A and a table B. A has a foreign key to B on B's primary key, B_ID.

出于某种原因(我知道有正当理由)它没有使用索引当我在密钥上加入这两个表时。

For some reason (I know there are legitimate reasons) it is not using an index when I join these two tables on the key.

我是否需要在 A.B_ID 上单独创建索引或者是否存在外键提供?

Do I need to separately create an index on A.B_ID or should the existence of a foreign key provide that?

推荐答案

仅外键约束不提供索引 - 必须(并且应该创建。

The foreign key constraint alone does not provide the index - one must (and should) be created.

这篇关于我是否需要在外键上创建索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆