问题描述
我现在正在开发Oracle。我有几个表,我定义了FOREIGN KEY约束。我已经阅读了这个的导向,但是我找不到任何有关Oracle的信息。 >所以问题总是相同的:为了优化查询性能,对于创建FOREIGN KEY约束的那些列,我是否也必须创建一个显式的二级索引?不会自动在FOREIGN KEYED列上创建一个索引来提高JOIN期间的性能吗?
我通常执行WHERE子句与这些列进行比较的查询。不,Oracle不会在外键列上自动创建索引,即使在99%的情况下,您可能也应该这样做。除了帮助查询外,索引还提高了父表上删除语句的性能。
I'm currenly developing on Oracle. I have several tables for which I defined FOREIGN KEY constraints. I have already read this SQL Server-oriented and this MySQL-oriented questions but I could find none about Oracle.
So the question is always the same: in order to optimize query performance, for those columns for which I create a FOREIGN KEY constraint, do I also have to create an explicit secondary index? Doesn't Oracle automatically create an index on FOREIGN KEYed columns to boost performances during JOINs?
I usually perform queries in which the WHERE clause compare against those columns.
No, Oracle doesn't automatically create indexes on foreign key columns, even though in 99% of cases you probably should. Apart from helping with queries, the index also improves the performance of delete statements on the parent table.
这篇关于Oracle是否自动为FOREIGN KEY列创建二级索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!