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

  • Home
  • SEARCH
  • 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 7627389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:27:10+00:00 2026-05-31T05:27:10+00:00

Im currently developing an application that needs to store a 10 to 20 digit

  • 0

Im currently developing an application that needs to store a 10 to 20 digit value into the database.

My question is, what datatype should i need to be using? This digit is used as an primary key, and therefore the performance of the DB is important for my accplication. In Java i use this digit as and BigDecimal.

  • 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-31T05:27:11+00:00Added an answer on May 31, 2026 at 5:27 am

    Quote from the manual:

    numeric: up to 131072 digits before the decimal point; up to 16383 digits after the decimal point

    http://www.postgresql.org/docs/current/static/datatype-numeric.html

    131072 digits should cover your needs as far as I can tell.

    Edit:
    To answer the question about efficiency:

    The first and most important question is: what kind of data is stored in that column and how do you use it?

    • If it’s a number then use numeric.
    • If it’s not a number use a varchar.

    Never, ever store (real) numbers in character columns!

    If you need to sort by that column you won’t be satifisfied with what you get if you use a character datatype (e.g. 2 will be sorted after 10)

    Coming back to the efficiency question. I assume this is mostly space efficiency you are concerned. You can calculate the space requirements for your values yourself.

    The storage requirement for the numeric data type is documented as well:

    The actual storage requirement is two bytes for each group of four decimal digits, plus five to eight bytes overhead

    So for 20 digits this would be a maximum of 10 bytes plus the five to eight bytes overhead. So max. 18 bytes.

    To store 20 digits in a varchar column you need 21 bytes.

    So from a space “efficiency” point of view numeric is slightly better. But that should never influence your decision, because the choice of datatypes should be driven by the requirements of the column’s content.

    From a performance point of view I don’t think there will be a big difference either.

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

Sidebar

Related Questions

I'm currently developing an application that needs to store data in it's on database,
I'm currently developing a PHP application that's using an Access database as a backend.
I am currently developing a Rails application using a database that was designed before
In the small application that I'm currently developing for a customer I need to
I am currently developing a web application that receives data from an on-site database.
I'm currently developing an Android application that fetches images using http requests. It would
I am in the process of developing a desktop application that needs a database.
I'm currently developing an application that needs to parse some (a big file of)
I'm currently developing an application that needs to communicate with a webservice on the
I am currently developing an application in C# using WPF. I need the program

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.