Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable binding performance #7

Open
K0Te opened this issue Sep 9, 2015 · 0 comments
Open

Variable binding performance #7

K0Te opened this issue Sep 9, 2015 · 0 comments

Comments

@K0Te
Copy link
Contributor

K0Te commented Sep 9, 2015

Hi,
I've profiled cx_oracle_on_ctypes on PyPy-2.6.1 with vprof profiler. vprof is a statistical profiler, so it shouldn't affect relative time, spent in different code parts.
Results show that for simple INSERT with 2 variables:

import cx_Oracle

conn = cx_Oracle.connect('user/pass@DB')
cr = conn.cursor()
sql = 'INSERT INTO TEST(num, chr) values(:num, :chr)'
for i in range(10**3):
    cr.execute(sql, {'num': i, 'chr': 'test_string'})
conn.commit()
cr.close()
conn.close()

68% of CPU time is spent on variable binding, and 27% is spent on execute().
Here are profiling results:

 100.0%  <module>                      t.py:1
 69.3%   execute                       cx_Oracle/cursor.py:265
 46.0%   set_bind_variables            cx_Oracle/cursor.py:160
 45.3%   set_bind_variable_helper      cx_Oracle/cursor.py:209
 43.9%   set_value                     cx_Oracle/variable.py:225
 43.5%   set_single_value              cx_Oracle/variable.py:237
 32.4%   __call__                      /usr/lib64/pypy-2.6.1/lib_pypy/_ctypes/function.py:710
 29.9%   <module>                      cx_Oracle/__init__.py:1
 26.5%   _call_funcptr                 /usr/lib64/pypy-2.6.1/lib_pypy/_ctypes/function.py:368
 20.7%   internal_execute              cx_Oracle/cursor.py:135
 20.1%   set_value                     cx_Oracle/numbervar.py:136
 19.8%   <module>                      cx_Oracle/custom_exceptions.py:1
 19.8%   <module>                      cx_Oracle/utils.py:1
 19.8%   <module>                      cx_Oracle/oci.py:1
 17.7%   set_value                     cx_Oracle/stringvar.py:98
 15.8%   set_value_from_integer        cx_Oracle/numbervar.py:232
 11.6%   <module>                      cx_Oracle/oci_generated_11.py:1
 8.9%    _as_ffi_pointer_              /usr/lib64/pypy-2.6.1/lib_pypy/_ctypes/pointer.py:125
 7.7%    <module>                      cx_Oracle/oci_generated_12.py:1
 7.2%    new_from_object               cx_Oracle/buffer.py:36
 7.0%    set_row_count                 cx_Oracle/cursor.py:354
 6.7%    OCIAttrGet                    cx_Oracle/pythonic_oci.py:7
 6.3%    load_library                  cx_Oracle/oci_generated_12.py:359
 6.3%    getpaths                      cx_Oracle/oci_generated_12.py:383
 6.3%    __setitem__                   /usr/lib64/pypy-2.6.1/lib_pypy/_ctypes/array.py:185
 6.2%    _compile                      /usr/lib64/pypy-2.6.1/lib-python/2.7/re.py:230
 6.2%    getplatformpaths              cx_Oracle/oci_generated_12.py:519
 6.2%    compile                       /usr/lib64/pypy-2.6.1/lib-python/2.7/re.py:192
 6.2%    compile                       /usr/lib64/pypy-2.6.1/lib-python/2.7/sre_compile.py:567
 5.4%    _create_ld_so_cache           cx_Oracle/oci_generated_12.py:457
 4.7%    glob                          /usr/lib64/pypy-2.6.1/lib-python/2.7/glob.py:18

I've checked code, however it is not clear if it is possible to improve variable binding performance.
Please advise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant