tasks optimization / celery - improve sql queries