I am creating a table wich will contain user-provided URLs. I want those to be unique, so when the user gives me a URL I will first check if the URL exists and if so return the ID for the entry. If not create a new row with this URL.
Obviously I want this to be fast. What is the best option?
- Make the actual URL a varchar that is UNIQUE and look by this url?
- Make a hash of the URL and use it as a primary key of sort?
- Other ideas?