[cx-oracle-users] Python 2: unicode vs str param causing slowness
Brought to you by:
atuining
|
From: Dayton G. <Day...@sy...> - 2015-01-20 15:56:02
|
This very well could be the oracle server, but I figure I could ask here. Perhaps someone has run into this and could guide me in a better direction.
I have a table, let's call it "device", that has lots of rows. It has a column, "platform", that's NVARCHAR2(20) and has an index on it. In python, when I execute a query on the data using a unicode object as a parameter, the whole query slows down from .1 seconds to over 100 seconds.
100 seconds:
cursor.execute('''SELECT COUNT(*) FROM "device" WHERE "PLATFORM" = :platform''', {'platform': u'ios'})
.1 seconds:
cursor.execute('''SELECT COUNT(*) FROM "device" WHERE "PLATFORM" = :platform''', {'platform': 'ios'})
Another interesting fact is that the slowness happens on 11g, but not oracle 12c. 12c seems to operate just fine with either. Both have:
NLS_CHARACTERSET WE8MSWIN1252
NLS_NCHAR_CHARACTERSET AL16UTF16
I'm using django as a layer of abstraction above cx_Oracle, and django seems to make everything unicode before the query is sent. So string conversion beforehand is likely not an option.
Is there some… oracle-side setting I'm missing? Or maybe some encoding/decoding setting in cx_Oracle?
Thanks much!
|