July 5, 2010 at 4:46 am
[font="Verdana"]Do Foreign key constraint implementation is fatal in terms of performance (keeping in view all CRUD Operations).
My design strategy for a medium level transactional DB (10 K - 500 K data records/Day) would be to not implement foreign key constraints?
How we can set any tradeoff between these two concerned factors.
Waiting Expertise !!!
[/font]
July 5, 2010 at 4:58 am
If you have a relational databae then you need to have FK constraints, without them you may as well look at column database.
The FK can impact perfromance, however they can also be used by the Query Optimizer for optimizing queries.
July 5, 2010 at 5:12 am
Abrar Ahmad_ (7/5/2010)
My design strategy for a medium level transactional DB (10 K - 500 K data records/Day) would be to not implement foreign key constraints?
Half a million records a day is not a high-volume SQL database, not on appropriate hardware. There's no need to go to extreme measures (like dropping constraints) on a transactional volume that small.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 5, 2010 at 8:15 am
Abrar Ahmad_ (7/5/2010)
Do Foreign key constraint implementation is fatal in terms of performance
FKs certainly add overhead but I would refrain myself of saying that FK implementation is fatal in terms of performance.
Having said that I have seen critical, high end systems - 60K+ executions per second - where each millisecond counted then no PK/FK was defined. In this case PKs got replaced by unique indexes and RI was enforced at the app side.
Abrar Ahmad_ (7/5/2010)
My design strategy for a medium level transactional DB (10 K - 500 K data records/Day) would be to not implement foreign key constraints?
There is a big difference in between 10K and 500K inserts nevertheless I agree with Gail this is not a large volume and provided hardware is appropriate I would enforce referential integritiy on the backend e.g. define PKs/FKs as business rules ask for.
Hope this helps.
_____________________________________
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.July 6, 2010 at 3:00 am
PaulB-TheOneAndOnly (7/5/2010)
FKs certainly add overhead but I would refrain myself of saying that FK implementation is fatal in terms of performance.Having said that I have seen critical, high end systems - 60K+ executions per second - where each millisecond counted then no PK/FK was defined. In this case PKs got replaced by unique indexes and RI was enforced at the app side.
Hope this helps.
[font="Verdana"]
Thanks Paul,
Do overhead of constraints is same for all CRUD Operations. Or there are some differences?
[/font]
July 7, 2010 at 2:48 pm
Abrar Ahmad_ (7/6/2010)
Do overhead of constraints is same for all CRUD Operations. Or there are some differences?
No doubt a select statement on a single table will show no overhead because of Referential Integrity 🙂
In regards of Insert, Update and Delete operations it all depends on the RI overall structure.
Inserting a row in a table where RI forces RDBMS engine to check the existance of - lets say 10 parent records in 10 different tables will have more impact than inserting a row in a table where rows have just one parent. The same applies to update and delete operations.
_____________________________________
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.July 8, 2010 at 10:04 am
For well designed relational databases, foreign key (FK) constraints are not optional. They play a significant role in maintaining referential integrity. Having stated that principle, it is possible to place too many FK constraints on a given table and significantly degrade performance. However, this is most often a symptom of poor database design and not an indictment of FK constraints.
If you are concerned that specific FK constraints may degrade performance, then generate and examine the query execution plans for all related CRUD statements.
If the evidence points to FK constraints as being the root cause of the bottleneck, then refactor the physical database schema with the aim to reduce the number of FK constraint on a given table, but without sacrificing overall referencial integrity (enforced by the FKs).
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply