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 ? Link to comment https://forums.phpfreaks.com/topic/249472-integer-or-text/ 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. Link to comment https://forums.phpfreaks.com/topic/249472-integer-or-text/#findComment-1280885 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 Link to comment https://forums.phpfreaks.com/topic/249472-integer-or-text/#findComment-1280890 Share on other sites More sharing options...
manix Posted October 20, 2011 Author Share Posted October 20, 2011 Nice, thanks! Link to comment https://forums.phpfreaks.com/topic/249472-integer-or-text/#findComment-1280894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.