PatPHP Posted February 22, 2009 Share Posted February 22, 2009 Hi I'm developing on a program where many URLS will saved into mysql. Now my question is what is the best data type to use for that purpose so that it is still fast to access and requires not too much space? So varchar(2000) or text? Which one is faster and which one uses less space? Which collation is good for URLs? I won't do any search in them. I will just access them via id number. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/146339-save-url-in-into-mysql-table/ Share on other sites More sharing options...
dreamwest Posted February 22, 2009 Share Posted February 22, 2009 Im using varchar(255) for my urls . You proberly wont need varchar(2000) for urls, Ive never seen a url with 2000 characters, besides itll slow down your query Quote Link to comment https://forums.phpfreaks.com/topic/146339-save-url-in-into-mysql-table/#findComment-768297 Share on other sites More sharing options...
fenway Posted February 23, 2009 Share Posted February 23, 2009 When the last time you saw a URL > 255 chars? Quote Link to comment https://forums.phpfreaks.com/topic/146339-save-url-in-into-mysql-table/#findComment-769055 Share on other sites More sharing options...
PatPHP Posted February 23, 2009 Author Share Posted February 23, 2009 True actually 256 characters is quite long and will be long enough for my purpose. So I will limit it to that at the moment. Quote Link to comment https://forums.phpfreaks.com/topic/146339-save-url-in-into-mysql-table/#findComment-769092 Share on other sites More sharing options...
dreamwest Posted February 23, 2009 Share Posted February 23, 2009 263 chars http://www.google.com/search?hl=en&lr=&c2coff=1&rls=GGLG%2CGGLG%3A2005-26%2CGGLG%3Aen&q=http%3A%2F%2Fwww.google.com%2Fsearch%3Fhl%3Den%26lr%3D%26c2coff%3D1%26rls%3DGGLG%252CGGLG%253A2005-26%252CGGLG%253Aen%26q%3Dhttp%253A%252F%252Fwww.google.com%252Fsearch%253Fhl%253Den%2526lr%253D%2526c2coff%253D1%2526rls%253DGGLG%25252CGGLG%25253A2005-26%25252CGGLG%25253Aen%2526q%253Dhttp%25253A%25252F%25252Fwww.google.com%25252Fsearch%25253Fsourceid%25253Dnavclient%252526ie%25253DUTF-8%252526rls%25253DGGLG%25252CGGLG%25253A2005-26%25252CGGLG%25253Aen%252526q%25253Dhttp%2525253A%2525252F%2525252Fwww%2525252Egoogle%2525252Ecom%2525252Fsearch%2525253Fsourceid%2525253Dnavclient%25252526ie%2525253DUTF%2525252D8%25252526rls%2525253DGGLG%2525252CGGLG%2525253A2005%2525252D26%2525252CGGLG%2525253Aen%25252526q%2525253Dhttp%252525253A%252525252F%252525252Fuk2%252525252Emultimap%252525252Ecom%252525252Fmap%252525252Fbrowse%252525252Ecgi%252525253Fclient%252525253Dpublic%2525252526GridE%252525253D%252525252D0%252525252E12640%2525252526GridN%252525253D51%252525252E50860%2525252526lon%252525253D%252525252D0%252525252E12640%2525252526lat%252525253D51%252525252E50860%2525252526search%252525255Fresult%252525253DLondon%25252525252CGreater%252525252520London%2525252526db%252525253Dfreegaz%2525252526cidr%252525255Fclient%252525253Dnone%2525252526lang%252525253D%2525252526place%252525253DLondon%252525252CGreater%252525252BLondon%2525252526pc%252525253D%2525252526advanced%252525253D%2525252526client%252525253Dpublic%2525252526addr2%252525253D%2525252526quicksearch%252525253DLondon%2525252526addr3%252525253D%2525252526scale%252525253D100000%2525252526addr1%252525253D%2526btnG%253DSearch%26btnG%3DSearch&btnG=Search Quote Link to comment https://forums.phpfreaks.com/topic/146339-save-url-in-into-mysql-table/#findComment-769511 Share on other sites More sharing options...
jackpf Posted February 23, 2009 Share Posted February 23, 2009 Lol, you googled longest url in the world? xD Quote Link to comment https://forums.phpfreaks.com/topic/146339-save-url-in-into-mysql-table/#findComment-769519 Share on other sites More sharing options...
corbin Posted February 24, 2009 Share Posted February 24, 2009 You could of course use TEXT if you want a dynamically [max] sized field, but in reality, when are users going to submit super long URLs? As for collation, what collation do you think you'll need? Will people submit URLs with all kind of languages or mostly English? If 100% English (or other characters in the ASCII table), something that can handle ASCII would work fine. If you would have other languages, I would go with a collation that can do UTF8 or UTF16. Quote Link to comment https://forums.phpfreaks.com/topic/146339-save-url-in-into-mysql-table/#findComment-769694 Share on other sites More sharing options...
PatPHP Posted February 24, 2009 Author Share Posted February 24, 2009 They would be all different kind of languages but aren't all url just in normal ascii code? Quote Link to comment https://forums.phpfreaks.com/topic/146339-save-url-in-into-mysql-table/#findComment-769960 Share on other sites More sharing options...
fenway Posted February 24, 2009 Share Posted February 24, 2009 They would be all different kind of languages but aren't all url just in normal ascii code? Nope. But anyway, MySQL 5 allows for 65K varchars, which are better than text fields. Quote Link to comment https://forums.phpfreaks.com/topic/146339-save-url-in-into-mysql-table/#findComment-770182 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.