manix Posted October 20, 2011 Share Posted October 20, 2011 Hey, I have this brainstorm whether I should store id's as integers or text? I mean in my database, since my IDs start from like 1319129364 which is a rather large number, I was thinking if it would be better to save it as text? Which case requires less memory ? Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 20, 2011 Share Posted October 20, 2011 If they are numbers store them as numbers. An int of x number of characters would take less memory than a varchar of the same number of characters. Quote Link to comment Share on other sites More sharing options...
xyph Posted October 20, 2011 Share Posted October 20, 2011 Integers. ASCII is 8 bits per character. Each time you add a bit to an integer, the maximum size double. String '1319129364' = 80 bits. Integer 1319129364 = 31 bits. Keep in mind, the largest signed integer is ~2^31 The largest unsigned integer (no negatives) is ~2^32 Quote Link to comment Share on other sites More sharing options...
manix Posted October 20, 2011 Author Share Posted October 20, 2011 Nice, thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.