Do foreign key constraints influence query transformations in Oracle?

前端 未结 2 1207
执念已碎
执念已碎 2020-12-16 01:22

I have a situation like this:

create table a(
  a_id number(38) not null,
  constraint pk_a primary key (id)
);

create table b(
  a_id number(38) not null
)         


        
2条回答
  •  北海茫月
    2020-12-16 01:43

    As Justin already pointed out, JOIN elimination is an essential non-cost based SQL transformation, which can be applied based on the presence of meta data only. I have blogged about this more recently:

    • JOIN Elimination: An Essential Optimiser Feature for Advanced SQL Usage
    • 10 Cool SQL Optimisations That do not Depend on the Cost Model

    As I originally assumed, there are a lot of SQL transformations that depend on meta data, so adding foreign key constraints (and other constraints) definitely can impact performance in a positive way.

提交回复
热议问题