patternsqlModerate
Data Compression Through Base36 Encoding
Viewed 0 times
throughcompressionencodingdatabase36
Problem
I'm trying to store a lot of large numbers that truncate when stored as
I'm thinking about using Base36 encoding to accomplish this. Are there any other ways to go about fixing this problem?
INT values. Unfortunately they are too large for this type.I'm thinking about using Base36 encoding to accomplish this. Are there any other ways to go about fixing this problem?
Solution
More often than not,
See PHP's documentation for a thorough explanation on the loss of precision.
Answer: You should be using BIGINT for your operations.
Base36 encoding will lead to a loss of precision as the base conversion process requires floating point number operations. Not only will this corrupt your data when converting to and from Base36, you will also be consuming more space (INT takes up 4 bytes, many Base36-encoded integers near the 32-bit unsigned integral limit will take up more than this).See PHP's documentation for a thorough explanation on the loss of precision.
Answer: You should be using BIGINT for your operations.
Context
StackExchange Database Administrators Q#23203, answer score: 13
Revisions (0)
No revisions yet.