Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1018695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:53:47+00:00 2026-05-16T10:53:47+00:00

I came across a question recently that was for Generating primary key in a

  • 0

I came across a question recently that was for “Generating primary key in a clustered environment of 5 App-Servers – [OAS Version 10] without using database”.

Usually we generate PK by a DB sequence, or storing the values in a database table and then using a SP to generate the new PK value…However current requirement is to generate primary key for my application without referencing the database using JDK 1.4.

Need expert’s help to arrive on better ways to handle this.

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:53:48+00:00Added an answer on May 16, 2026 at 10:53 am

    Use a UUID as your primary key and generate it client-side.

    Edit:
    Since your comment I felt I should expand on why this is a good way to do things.

    Although sequential primary keys are the most common in databases, using a randomly generated primary key is frequently the best choice for distributed databases or (particularly) databases that support a “disconnected” user interface, i.e. a UI where the user is not continuously connected to the database at all times.

    UUIDs are the best form of randomly generated key since they are guaranteed to be very unique; the likelyhood of the same UUID being generated twice is so extremely low as to be almost completely impossible. UUIDs are also ubiquitous; nearly every platform has support for the generation of them built in, and for those that don’t there’s almost always a third-party library to take up the slack.

    The biggest benefit to using a randomly generated primary key is that you can build many complex data relationships (with primary and foreign keys) on the client side and (when you’re ready to save, for example) simply dump everything to the database in a single bulk insert without having to rely on post-insert steps to obtain the key for later relationship inserts.

    On the con side, UUIDs are 16 bytes rather than a standard 4-byte int — 4 times the space. Is that really an issue these days? I’d say not, but I know some who would argue otherwise. The only real performance concern when it comes to UUIDs is indexing, specifically clustered indexing. I’m going to wander into the SQL Server world, since I don’t develop against Oracle all that often and that’s my current comfort zone, and talk about the fact that SQL Server will by default create a clustered index across all fields on the primary key of a table. This works fairly well in the auto-increment int world, and provides for some good performance for key-based lookups. Any DBA worth his salt, however, will cluster differently, but folks who don’t pay attention to that clustering and who also use UUIDs (GUIDs in the Microsoft world) tend to get some nasty slowdowns on insert-heavy databases, because the clustered index has to be recomputed every insert and if it’s clustered against a UUID, which could put the new key in the middle of the clustered sequence, a lot of data could potentially need to be rearranged to maintain the clustered index. This may or may not be an issue in the Oracle world — I just don’t know if Oracle PKs are clustered by default like they are in SQL Server.

    If that run-on sentence was too hard to follow, just remember this: if you use a UUID as your primary key, do not cluster on that key!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently came across a question about sequence points in C++ at this site,
I recently came across a question somewhere: Suppose you have an array of 1001
Recently I came across a character range that was the following: [/-+] My very
I recently came across a CSS pseudo class that can do an effect for
I came across this recently and thought it would make a great SO question.
I came across this issue recently and thought it was really helpful. My question
I recently came across a bit of not-well-tested legacy code for writing data that's
I recently came across this question What is the BEST-WORST case time to add
I recently came across a Microsoft Interview Question for Software Engineer. Given an array
I was working on some code recently and came across a method that had

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.