Richard Davies wrote:
> That's an interesting article, and I follow your logic. However,
> Jack's original patch follows from profiling work he did on his
> Chesspark site (see 
> http://metajack.wordpress.com/2007/07/25/do-you-know-what-your-database-is-doing/
> ) in which he claimed a 2-3x speed improvement from changing to auto-
> commit mode. I haven't done the equivalent testing myself, and would
> be interested in an explanation of why your article and his tests give
> such different conclusions.

I've done a quick non-scientific test. Here's the code:

         c = psycopg2.connect(...)
 
c.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
         cursor = c.cursor()
         now = datetime.now()
         for x in range(1000):
             cursor.execute('select created from cicero_article where id 
= %s', [x])
             res = cursor.fetchall()
         c.commit()
         print datetime.now() - now

For the record, 'select' there does a fetch by primary key from a ~6500 
record table (i.e. -- fast). The results of executing 1000 selects are:

ISOLATION_LEVEL_AUTOCOMMIT:     ~0.29 sec
ISOLATION_LEVEL_READ_COMMITTED: ~0.26 sec

So the default level is indeed faster but I have to confess I'm a lousy 
tester so I encourage anybody to conduct their own experiment.

Also this observation matches psycopg2 docs[1]:

> `ISOLATION_LEVEL_READ_COMMITTED` This is the default value.  A new
> transaction is started at the first `.execute()` command on a cursor
> and at each new `.execute()` after a `.commit()` or a `.rollback()`.

Which conflicts with what 3460 states[2]:

> The difference between autocommit and read committed is that read
> committed in psycopg2 puts all statements inside a BEGIN/END block
> (or BEGIN/ROLLBACK or BEGIN/COMMIT).

Jack, can you comment?

[1]: http://www.initd.org/svn/psycopg/psycopg2/trunk/doc/extensions.rst
[2]: http://code.djangoproject.com/ticket/3460

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to