mathew
mathew

Reputation: 1200

md5 hash for urls in unique Index

I was asked this before with slight different with current question. but did not got the answer I was looking into.

My question is do I need to store md5($url) in unique index in MySQL?? I have seen this in some code actually I don't remember..this is a large database with more than 5 million urls and the indexing is done by calling urls.

Any ideas?

Upvotes: 2

Views: 2666

Answers (3)

Alix Axel
Alix Axel

Reputation: 154563

I don't think you should hash your URLs. The only plausible reason would be to save space (if most of the URLs are larger than 32 chars) at the expense of increased risk of collisions.

What you should do is normalize the URLs.

Upvotes: 2

ivan73
ivan73

Reputation: 705

Some sites uses hashing for urls in the database because they use hashes in urls say for user redirect to external url. I can't see any reason to do this if this is not the case.

Upvotes: 1

jim tollan
jim tollan

Reputation: 22485

are you saying that the url is called as such:

www.yourdomain.com?id=89ce9250e9f469c9d1816e1cc0fb47a1

and then the id (89ce9250e9f469c9d1816e1cc0fb47a1 which is an md5() of the real url querystring) is looked up from the database to resolve the actual url which could be:

www.yourdomain.com?user=23&location=5&eventtype=23&year=2010

Is this the kind of usage you're referring to??

jim

Upvotes: 0

Related Questions