Author Topic: save url in into mysql table  (Read 1148 times)

0 Members and 1 Guest are viewing this topic.

Offline PatPHPTopic starter

  • Irregular
    • View Profile
save url in into mysql table
« on: February 22, 2009, 02:08:35 AM »
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.
« Last Edit: February 22, 2009, 02:09:32 AM by PatPHP »

Offline dreamwest

  • Devotee
  • Gender: Male
    • View Profile
Re: save url in into mysql table
« Reply #1 on: February 22, 2009, 02:39:16 AM »
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
My code doesn't have bugs...Just unexpected benefits

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Insane!'
  • *
  • Gender: Male
    • View Profile
Re: save url in into mysql table
« Reply #2 on: February 23, 2009, 06:47:17 AM »
When the last time you saw a URL > 255 chars?
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

Offline PatPHPTopic starter

  • Irregular
    • View Profile
Re: save url in into mysql table
« Reply #3 on: February 23, 2009, 07:57:19 AM »
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.
« Last Edit: February 23, 2009, 08:06:37 AM by PatPHP »

Offline dreamwest

  • Devotee
  • Gender: Male
    • View Profile
Re: save url in into mysql table
« Reply #4 on: February 23, 2009, 04:38:29 PM »
263 chars

Code: [Select]
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
My code doesn't have bugs...Just unexpected benefits

Offline jackpf

  • Devotee
  • Gender: Male
    • View Profile
    • Jack's Website
Re: save url in into mysql table
« Reply #5 on: February 23, 2009, 04:46:18 PM »
Lol, you googled longest url in the world? xD

Offline corbin

  • Guru
  • Freak!
  • *
  • Gender: Male
    • View Profile
Re: save url in into mysql table
« Reply #6 on: February 23, 2009, 08:06:08 PM »
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.
Why doesn't anyone ever say hi, hey, or whad up world?

Offline PatPHPTopic starter

  • Irregular
    • View Profile
Re: save url in into mysql table
« Reply #7 on: February 24, 2009, 05:58:40 AM »
They would be all different kind of languages but aren't all url just in normal ascii code?

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Insane!'
  • *
  • Gender: Male
    • View Profile
Re: save url in into mysql table
« Reply #8 on: February 24, 2009, 11:28:18 AM »
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.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.