Opened 12 months ago

Last modified 11 months ago

#20689 new Bug

Django 1.5.1: severe performance degradation on Oracle

Reported by: zakharov.vv@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.5
Severity: Normal Keywords: Oracle, cx_oracle, unicode
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


After migrating to Django 1.5.1, several queries takes thousands times more time comparing to Django 1.4.5.

Example query generated by ORM:

SELECT COUNT(*) FROM "TICKETS" WHERE ("TICKETS"."T_TYPE" IN (:arg0, :arg1, :arg2, :arg3) AND "TICKETS"."T_PARTNER_CODE" = :arg4 AND "TICKETS"."T_CHANEL" = :arg5 AND "TICKETS"."T_WORKER_CODE" = :arg6 AND "TICKETS"."T_CDATE" <= :arg7 AND "TICKETS"."T_CDATE" >= :arg8 )

Django 1.4.5: ~7ms
Django 1.5.1: ~193574ms (about 27000 times more!)

git bisect points to this commit: Indeed, forcing convert_unicode to be equal to force_bytes solves the issue.

The only found difference is in params to query:
Django 1.4.5:

[1, 38, 76, 92, '777-61', 61, 'pupkin', '2013-07-03 00:00:00', '2013-06-01 00:00:00']

Django 1.5.1:

[1, 38, 76, 92, u'777-61', 61, u'pupkin', u'2013-07-03 00:00:00', u'2013-06-01 00:00:00']

Django 1.5.1 hangs on this string (django/db/backends/oracle/

            return self.cursor.execute(query, self._param_generator(params))

Directly using cx_Oracle for this query shows no difference for two variants of query params.

Used versions:

  • cx-Oracle 5.1.2
  • instantclient (same for instantclient
  • Oracle Database 10g Enterprise Edition Release - 64bit Production

Attachments (0)

Change History (2)

comment:1 Changed 12 months ago by zakharov.vv@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

It seems, that issue affects only large tables. Table from example in description has about 100 million records. For small tables (thousands records) query time doesn't change after upgrading to 1.5.1.

comment:2 Changed 11 months ago by wim@…

  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

Accepted. If you would like to contribute and would like to submit a patch (or even a pull request), you are welcome to do so!

Add Comment

Modify Ticket

Change Properties
<Author field>
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.