Hi Django developers, I've been working with Oracle on a project with some performance requirements, and we've noticed long ago that the Django Oracle backend performs significantly worse than other backends; we've been able to profile it and see that, indeed, a lot of time is spent in processing the returned rows, while the Oracle DBMS itself is not breaking a sweat.
This week, I found what is, I think, the main culprit: The Oracle backend prefers accuracy to performance. Since Oracle numbers can have more significant digits than C doubles (=CPython floats), and the backend wishes to preserve this accuracy, it makes cxOracle (the Python Oracle client library) return all numbers as strings, and then converts the strings back to numbers -- ints, floats or decimals -- according to the Oracle data type descriptions. To make things even slower, the conversion decisions are made anew for each row; this is done in the function _rowfactory (currently at https://github.com/django/django/blob/master/django/db/backends/oracle/base.py#L790). The function itself is called less efficiently than possible (on rows returned from cxOracle, instead of within cxOracle before the rows are returned). For our application -- as for many others, I guess -- precision of 38 digits, on real numbers or integers, is not important. I made a modified backend which returns numbers as numbers and the improvement in performance is very significant. A row-factory function is still required to make sure strings are returned as unicode, and creating such a function per query to only go over the string columns may improve things even more, but I didn't even have to go there yet. Can we put this into Django core? Perhaps with a Settings knob for people who really need all the precision? Thanks, Shai. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.