Subject Re: [firebird-support] Foreign Key & Query Performance
Author liviuslivius
Show query plans for both situatios fk an index.



Regards,
Karol Bieniaszewski

-------- Oryginalna wiadomość --------
Od: "antoedincharley@... [firebird-support]" <firebird-support@yahoogroups.com>
Data: 24.02.2018 11:40 (GMT+01:00)
Do: firebird-support@yahoogroups.com
Temat: [firebird-support] Foreign Key & Query Performance

 

Hello there,

I am having a doubt that if Foreign Key reduces Query Performance Or not.


My Environment is 

FirebirdCS2.6 :-

Item Table :- 10 Records, PK - Itemcode Varchar(5);

BillDetail Table :- 10 Million Records (FK Selectivity - 0.0076, PK Selectivity - 0.000000076)


I am having FK between BillDetail.Itemcode And Item.Itemcode with FK every query is slow. but as i remove the FK and added Index with Itemcode&BillDetail_PK the queries are running lightning fast. But I prefer FK to be in Database with high performance queries.


Kindly share you suggestions and Feedbacks on the same.