Comments (12)
I just did a packet trace with thick mode and I am seeing a round trip for each attribute that is being set -- which should not be happening. I'll do some more investigation and get back to you.
from python-oracledb.
This is known behavior in thick mode. There is no round trip for each call to setattr() but there is a poor implementation in place in the Oracle Client libraries. I would recommend trying with thin mode.
from python-oracledb.
I created this script instead to use the timeit module:
import timeit
import oracledb
# oracledb.init_oracle_client()
conn = oracledb.connect('hello/password@foo')
r_foo_type = conn.gettype('HELLO.XXTEST_TEST_PKG.R_FOO')
r_foo_obj = r_foo_type.newobject() # No way to set all the attributes at once
result = timeit.timeit("value.BAR = 'a'", number=1000,
globals=dict(value=r_foo_obj))
print("result 1:", result)
result = timeit.timeit("value.BAR = 'a' * 4000", number=1000,
globals=dict(value=r_foo_obj))
print("result 2:", result)
On my machine, 1000 iterations takes about 100 ms in thick mode and < 1 ms in thin mode. No round trip to the database occurs in either mode.
from python-oracledb.
When I run from inside of my docker on my localhost, 1000 iterations took 141 seconds.
However running the same code on my normal computer, outside of docker, 1000 iterations took 0.076 seconds.
Running from inside of my docker on my remote server using the identical container image takes 0.70 seconds.
Seems like the combination of localhost and docker is the only place where there is any noticeable performance issue.
Any idea what could be causing this, or how I can debug it further? ldap.ora, sqlnet.ora etc. are all identical.
I've tried the following from both my local non-docker and my local docker, all perform about the same: opening and closing connections, select 1 from dual, callproc, callfunc,
from python-oracledb.
Are you able to use thin mode? Do you see the same behavior there?
from python-oracledb.
Unfortunately I cannot use thin mode because my database requires ldap to connect, which is not supported in oracledb's thin mode.
However, using a hack which I'm afraid to use in production, I cannot replicate this issue in thin mode.
Do you think something like this acceptable for me to use if I wanted to use thin mode? I got this from here.
import ldap3
import oracledb
def connect(schema, password, database):
with ldap3.Connection('my-ldap.com') as conn:
conn.search('cn=OracleContext,dc=my,dc=com', f"(cn={database})", attributes=['orclNetDescString'])
tns_string = conn.entries[0].orclNetDescString.value
print(tns_string)
return oracledb.connect(f'{schema}/{password}@{tns_string}')
I'm not sure if oracle thick mode handles ldap exactly like this under the hood or if it has a bunch of additional features.
from python-oracledb.
How the database connect string is looked up shouldn't matter, so I don't see there being any problem with using that approach. There are definitely a bunch of additional features but as noted in the issue you referenced very few people seem to use them -- and you seem to be yet another one!
I would recommend using this:
return oracledb.connect(user=schema, password=password, dsn=tns_string)
That avoids the necessity of having the driver parse the string you just created back into its constituent parts again!
The ability to support LDAP is on the (rather long) list of enhancements.
from python-oracledb.
Closing - no activity.
from python-oracledb.
Hi @cjbj and @anthony-tuininga
Anthony mentioned here:
I just did a packet trace with thick mode and I am seeing a round trip for each attribute that is being set -- which should not be happening. I'll do some more investigation and get back to you.
May we please keep this issue open until this is fixed?
from python-oracledb.
Sure
from python-oracledb.
@mkmoisen Anthony pointed me at the Oracle bug he logged for you. It is already fixed in a future version of Oracle Database. If you need a backport, contact Oracle Support and quote bug number 36299901.
from python-oracledb.
This has been corrected in 23ai which was just released today.
from python-oracledb.
Related Issues (20)
- Having issue setting up the connection with oracle database using oracledb module HOT 2
- dsn.py small fix to support NNE HOT 2
- create_pool_async requires asyncio and causes issues in pytest_asyncio HOT 4
- Add way to handle DPY-3007: database type "DB_TYPE_INTERVAL_YM" is not supported HOT 3
- Add support for IFILE in tnsnames.ora HOT 21
- Unable to make a connection via Thin Mode HOT 4
- Expose service names available in tnsnames.ora HOT 5
- Add iterator support for DbObject with collection content HOT 7
- Extrange case, do not work on server (error DPY-4011) but inside docker container same server works ok HOT 13
- Fallback by thick mode HOT 2
- Add sharding support to thin mode
- oracledb.connect_async hangs forever HOT 7
- cursor execute raise no_data_found without any exceptions HOT 3
- Does/will oracledb support SQL*Net compression in thin mode? HOT 3
- INVISIBLE column with custom %ROWTYPE type: unexpected end of data HOT 5
- Failover not working correctly
- TIMEDWAIT does not result in timeout before ping probe timeout
- Async select not returning all rows HOT 5
- python-oracledb 2.2 supports Oracle Database 23ai AI Vector Search
- ERROR: 'utf-8' codec can't decode byte 0x85 in position 0: invalid start byte HOT 18
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-oracledb.