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
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