Skip to Main Content
  • Questions
  • Can foreign key improves select query performance ?

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Pierre.

Asked: May 07, 2006 - 4:56 pm UTC

Last updated: May 08, 2006 - 10:11 am UTC

Version: 9.2

Viewed 1000+ times

You Asked

Hi Tom,

Suppose we have a slow SELECT query with several joined tables that don't have foreign keys constraints but they should have.
Now we create the missing foreign keys constraints: and that's the only change. Can these FK creation change something for the execution plan ? If yes, what ? Can the query run really faster ? Is it true in some cases or never true ?

Sorry for not having full example: this is something I've read in a forum and I would like to have your opinon about that.

Thanks !


and Tom said...

Well, if you also had materialized views - we would use the constraints to enable the use of query rewrite more frequently (so yes, in general, the more constraints the better - the optimizer uses this information).


</code> http://asktom.oracle.com/Misc/stuck-in-rut.html <code>


It could be true, yes. Depends on the physical structures you have in place and whether the newly added constraint allows us to use them more efficiently.


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Performance

Get all the information about database performance in the Database Performance guide.