Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Surrogate auto-generated VS natural primary keys with JPA
Surrogate auto-generated VS natural primary keys with JPA [message #661628] Fri, 25 March 2011 15:38 Go to next message
Eclipse User is currently offline Eclipse UserFriend
Messages: 4
Registered: March 2011
Junior Member
I am trying to understand if the use of surrogate auto-generated primary keys even in relational database tables which have a proper natural primary key may provide any efficiency gain from a JPA perspective (EclipseLink 2.0 in particular). Personally I'd like to avoid surrogate keys if not needed, but I am not sure if this has some implication on JPA performance.

Any help is very much appreciated.
Thanks
Re: Surrogate auto-generated VS natural primary keys with JPA [message #661977 is a reply to message #661628] Mon, 28 March 2011 17:34 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

If your natural Id is complex, then using a generated Id may provide some performance benefit.

If both are simple data-types, then I cannot see any benefit. Using the natural Id is probably more performant as people are more likely to query on it.

Generated Ids do have the benefit of always being unique, and never changing. Sometimes natural ids seemed to be unique or not change, but actually can change (such as ssn, name, phone number, email, etc.).


James : Wiki : Book : Blog : Twitter
Re: Surrogate auto-generated VS natural primary keys with JPA [message #662102 is a reply to message #661977] Tue, 29 March 2011 10:32 Go to previous message
Eclipse User is currently offline Eclipse UserFriend
Messages: 4
Registered: March 2011
Junior Member
Thanks James for taking your time to answer my question. I can see that you more or less apply concepts of relational database optimization, so I take it as if use of JPA should not affect the database design when it comes to efficiency matter.
Thanks.
Previous Topic:JPA2.1
Next Topic:Cascade persist and map keys
Goto Forum:
  


Current Time: Wed Apr 24 20:38:15 GMT 2024

Powered by FUDForum. Page generated in 0.05339 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top