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 519227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:01:09+00:00 2026-05-13T08:01:09+00:00

I am making an application to run on both SQL Server and PostgreSQL, so

  • 0

I am making an application to run on both SQL Server and PostgreSQL, so I am asking this question about both of them.

What happens whenever you create a unique primary key(using a sequence or auto-increment type thing) and you hit over 4 billion records(32 bits)? I’m not saying that our table will have 4 billion records but rather that 4 billion records have been created because the RID only increments. So even if I deleted 3.9 billion of these records, my RIDs are still in the 4 billion range. So what happens? Does it up the precision to 64 bit or does it roll over to 0 or just spit out a very critical error? Should I worry that even a 64 bit RID may eventually overflow also?

Also, how can I fight against this? Is there some kind of cleaning up option or tool? Do I just have to create my own thing to every year or so completely rebuild the table to get consistent RIDs? (and thus also touch a lot of other tables that use these RIDs are foreign keys)

  • 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-13T08:01:10+00:00Added an answer on May 13, 2026 at 8:01 am

    PostgreSQL will, by default, error and not overflow:

    # create sequence willyouwrap;
    CREATE SEQUENCE
    # select setval('willyouwrap', 9223372036854775807);
           setval        
    ---------------------
     9223372036854775807
    (1 row)
    # select nextval('willyouwrap');
    ERROR:  nextval: reached maximum value of sequence "willyouwrap" (9223372036854775807)
    

    From the docs:

    Sequences are based on bigint arithmetic, so the range cannot exceed the range of an eight-byte integer (-9223372036854775808 to 9223372036854775807). On some older platforms, there might be no compiler support for eight-byte integers, in which case sequences use regular integer arithmetic (range -2147483648 to +2147483647).

    However, you can make it cycle:

    The CYCLE option allows the sequence to wrap around when the maxvalue or minvalue has been reached by an ascending or descending sequence respectively. If the limit is reached, the next number generated will be the minvalue or maxvalue, respectively.

    If NO CYCLE is specified, any calls to nextval after the sequence has reached its maximum value will return an error. If neither CYCLE or NO CYCLE are specified, NO CYCLE is the default.

    Don’t fight it. Spend the extra bytes and keep things simple. You’re more likely to regret adding extra layers of complexity and/or maintenance tasks than having a larger keyspace.

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

Sidebar

Ask A Question

Stats

  • Questions 373k
  • Answers 373k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer NSDictionary. You can't simply say NSMutableDictionary *_myDict = [contentArray objectAtIndex:0];… May 14, 2026 at 7:37 pm
  • Editorial Team
    Editorial Team added an answer I fully support GMan and sbk who told you to… May 14, 2026 at 7:37 pm
  • Editorial Team
    Editorial Team added an answer It seems like you're overcomplicating things for no reason. ValueAtReturn… May 14, 2026 at 7:37 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.