Ah, you're correct, not sure what I was thinking of.
Alex
On Nov 28, 9:35 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-11-28 at 18:26 -0800, [EMAIL PROTECTED] wrote:
> > Can you try doing Country.objects.create(name=name) instead?
>
> Have a look at the implementation of crea
On Fri, 2008-11-28 at 18:26 -0800, [EMAIL PROTECTED] wrote:
> Can you try doing Country.objects.create(name=name) instead?
Have a look at the implementation of create(). It's not some kind of
secret sauce. It's a shortcut. We could remove it from Django and
nothing would be slower or less functi
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.
>
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
> cursor.execute("delete from app_country where name = %s", (name,))
> cursor.execute("insert into app_country (name) values (%s)", (name,))
>
> this is 5x faster than work with ORM.
1. Replace it with single update statement.
2. Do you use transactions? Like
django.db.transaction.commit_on_succ
I have following code:
class Country(models.Model):
name = models.CharField(max_length = 200, primary_key = True)
# ORM variant
for name in file:
models.Country(name = name).save()
# cursor variant
for name in file:
if cursor.execute("select * from app_country where name = %s",
(name,))
6 matches
Mail list logo