It’s quite common to load the entire data returned by your SQL queries in memory and then process them. This consumes a lot of memory and causes OOM issues in production as your data grows. To add to it, python is already memory hungry.
Consider a background job or