-2

I'm creating a web app with Django 3.1 and there's lots of DB interactions mostly between three tables. The queries mostly use results that are recent inputs. So query1 will run and update table1, query2 will use table1 to update2 table2 and query3 will use the column updated by query2 to update other columns of table2. All these run every time users input or update info. Perhaps a visual will be clearer.

query1 = Model1.objects.filter(...).annotate(...)
query2 = Model2.objects.filter(...).update(A=query1)
query3 = Model2.objects.filter(...).update(B=A*C)

I'm beginning to worry about speed between python and PostgreSQL and can lose data when multiple users start using it same time. I read about celery and Django Asynchronous support, but it's not clear if I need celery or not. This is a very simplified version but you get the gist. Can someone help me out here please.

quba
  • 123
  • 9

1 Answers1

3

You would consider using Celery if your Django view has a long running task and you don't want the user to wait for completion or for the application server to time out. If the database updates are quick then you probably do not need it. PostgreSQL is a multi-user database so you do not need to worry too much about users clobbering other users' changes.

Greg Cowell
  • 677
  • 5
  • 16