char0n / django-brevisurl

Django app for shortening urls
Other
9 stars 10 forks source link

Drop index on original_url and prevent a possible AttributeError exception #28

Open Ux2Daoch opened 7 years ago

Ux2Daoch commented 7 years ago

If the original_url field is longer than its hash, then it is more effective to drop the index on original_url and use the index on original_url_hash. Less storage space is used and the queries are processed faster.

In my case the average length of the original URLs is 140 characters. I suppose that there are many cases when the original URLs are shorter then 64 characters and the index on original_url offers better performance than the index on original_url_hash. I think however that the index on original_url_hash offers a good middle ground.