Can you try doing Country.objects.create(name=name) instead?

On Nov 28, 8:50 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-11-28 at 08:40 -0800, burb wrote:
>
> [...]
>
> > Code with cursor runs 100x faster than ORM code.
>
> [...]
>
> > this is 5x faster than work with ORM.
>
> > Where am I doing mistake in using Django ORM?
>
> The only mistake is assuming the ORM should be as fast as that raw SQL.
> The ORM is doing a lot more work (for a start, there's some transaction
> handling in there, as well as creating a bunch of Python objects). If
> you need to mass inserts, using the ORM is not going to be the fastest
> way. That's fine -- Django's ORM isn't designed to ever be a 100%
> replacement for interacting directly with the database in all
> circumstances.
>
> For creating a single object or a small group, using the ORM is fine,
> since the extra overhead is negligible when compared to all the other
> time consumed in a request/response cycle. If you subsequently need to
> work with the objects as Python objects, using the ORM for creatinv even
> a large number (using manual transaction control) *might* be worthwhile,
> but I would time it if I was doing this. It might be better to do the
> inserts using raw SQL and then use a single queryset to pull back the
> results into Python, too.
>
> So there's no problem here. You're just using the ORM to do a task it
> isn't particularly designed for. It's not that common for a website to
> need to do 100's of inserts all at once, for example. Perfectly
> acceptable to use raw SQL when you need to do that.
>
> Regards,
> Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to