Run the application using the following command:
python manage.py runserver
- Products Endpoint: http://127.0.0.1:8000/inventory/products
- Bulk Products Endpoint: http://127.0.0.1:8000/inventory/products-bulk
Run tests using the following command:
python manage.py test
Insert all products and their variants using the create
method sequentially.
Endpoint: http://127.0.0.1:8000/inventory/products
Test Results:
Insert products and their variants using the bulk_create
method.
Endpoint: http://127.0.0.1:8000/inventory/products-bulk
Test Results:
- Blulk Insertion solution has approximately less runtime than the sequential solution. Especially for the larger dataset as seen with the 1000 products the execution time decreased from 26.08s to 8.44s.
- There was a slight increase in memory for the bulk insertion solution compared to the sequential insertion solution
Solution 2 Bulk Insertion is the more optimal solution because of faster runtime