1

I running a script that uses Django ORM. The script runs for long time sometimes more than three days. Script looks like below

from app.models import *

for i in some_simpe_select():
    more_simple_selects()
    processing_for_few_minutes()
    new_object.save()

There are multiple instances for same script running simultaneously with slightly different options. We use postgresql. Over the time this causes DB CPU to go high. ps shows postgres processes idle in transaction but CPU usage unusually high.

I wonder what are best practices around long running django scripts, particularly around high db CPU usage.

Django 1.4, Python 2.7, Postgresql 9.1

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
Shekhar
  • 7,095
  • 4
  • 40
  • 45
  • reduce database touch to the minimum, try to make `more_simple_selects()` happen one time. note:queryset don't touch database until you start use it. – Moamen May 04 '13 at 08:23

0 Answers0