Skip to main content



      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 11:38 Go to next message
Eclipse UserFriend
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 13:34 Go to previous messageGo to next message
Eclipse UserFriend
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.).
Re: Surrogate auto-generated VS natural primary keys with JPA [message #662102 is a reply to message #661977] Tue, 29 March 2011 06:32 Go to previous message
Eclipse UserFriend
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: Tue Jul 22 12:49:36 EDT 2025

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

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

Back to the top