Django

Code

Changeset 4573

Show
Ignore:
Timestamp:
02/25/07 10:18:46 (2 years ago)
Author:
jacob
Message:

Fixed #3459: Django no longer runs SET TIME ZONE for every query when using Postgres. This should result in a pretty noticible speedup for Postgres users, so many thanks to Jack Moffitt for the patch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/backends/postgresql/base.py

    r4265 r4573  
    6161    def cursor(self): 
    6262        from django.conf import settings 
     63        set_tz = False 
    6364        if self.connection is None: 
     65            set_tz = True 
    6466            if settings.DATABASE_NAME == '': 
    6567                from django.core.exceptions import ImproperlyConfigured 
     
    7779            self.connection.set_isolation_level(1) # make transactions transparent to all cursors 
    7880        cursor = self.connection.cursor() 
    79         cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) 
     81        if set_tz: 
     82            cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) 
    8083        cursor = UnicodeCursorWrapper(cursor, settings.DEFAULT_CHARSET) 
    8184        if settings.DEBUG: 
  • django/trunk/django/db/backends/postgresql_psycopg2/base.py

    r4265 r4573  
    2929    def cursor(self): 
    3030        from django.conf import settings 
     31        set_tz = False 
    3132        if self.connection is None: 
     33            set_tz = True 
    3234            if settings.DATABASE_NAME == '': 
    3335                from django.core.exceptions import ImproperlyConfigured 
     
    4648        cursor = self.connection.cursor() 
    4749        cursor.tzinfo_factory = None 
    48         cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) 
     50        if set_tz: 
     51            cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) 
    4952        if settings.DEBUG: 
    5053            return util.CursorDebugWrapper(cursor, self)