network latency bugs in your software bugs in third party software slow template rendering misconfigured servers not enough threads “Our site’s too slow!”
heavy structure. Model.objects.filter(...).filter(...).order_by(...) •Model instantiation ~40k __init__s per second (see http://bit.ly/Muepgo). •Saving models Readable, but slow: m.foo = bar; m.save() Much much faster: Model.objects.filter(id=instance.id).update(foo=bar) 48
Book.objects.create(title=title) • Faster, but still terrible: with transaction.commit_on_success(): for title in big_title_list: Book.objects.create(title=title) • Fast: bl = [Book(title=t) for t in big_title_list] Book.objects.bulk_create(bl) • But COPY FROM wins, hands down. http://www.postgresql.org/docs/9.1/static/sql-copy.html http://initd.org/psycopg/docs/usage.html#using-copy-to-and-copy-from 49