char0n / django-brevisurl

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

URL shortening speed improvement #20

Closed Vladg90 closed 9 years ago

Vladg90 commented 10 years ago

I've made some improvements in the way ShortUrl objects are created: -add database index for original_url field; -use get_or_create QuerySet method; -if exception occurs, other than URL validation (violation of unique constraint) repeat the process of generating shortened_url and checking for token exhaustion until object is created.

I also perform tests using python timeit module with PostgreSQL database creating 10000 records.

Results (in seconds): Before changes: using autocommit mode: 201.8245 with commit_on_success: 104.3924

After: using autocommit mode: 146.3360 with commit_on_success: 48.5006

char0n commented 10 years ago

Sorry for taking so long. I will review the pull request during the week.