I want to store a 15 digit number in a table.
In terms of lookup speed should I use bigint
or varchar
?
Additionally, if it's populated with millions of records will the different data types have any impact on storage?
In terms of space, a bigint
takes 8 bytes while a 15-character string will take up to 19 bytes (a 4 bytes header and up to another 15 bytes for the data), depending on its value. Also, generally speaking, equality checks should be slightly faster for numerical operations. Other than that, it widely depends on what you're intending to do with this data. If you intend to use numerical/mathematical operations or query according to ranges, you should use a bigint
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With