-
Notifications
You must be signed in to change notification settings - Fork 365
Query parameter binding time increases exponentially with bind variable count #567
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
Comments
Did you dig into any DPI tracing to see whether the time is spent in Oracle Client code or the DB? Did you try the same statement using hard coded values, to see if it's the DB that is taking time, and whether some indexing etc would help? In general, if you're using 60K parameters I wonder if there aren't better solutions, such as loading into a global temp table, as mentioned in the doc - this suggestion originated from a (now) old Tom Kyte article. |
Thanks for the ideas Christopher, they were useful in understanding some of the complexity of this. My findings are:
So are the only options?:
Anything else? DPI_DEBUG_LEVEL=31, 65k bind variables and querying a table that doesn't exist:
Ignoring the part after the query is sent, time spent client side is split somewhat evenly between |
Thanks for the detail, which we'll mull over. I wonder if this is memory allocations? How much control do you have over the data? Unless you are repeating the query with exactly the same number of parameters, you are not going to get benefits from the statement cache or cursor reuse. You will get some security benefits, but if you have control over the data, perhaps you can filter it safely and build up the statement by concatenation. I wonder if some kind of analytic query is what you really need, but that isn't my area. |
I did some analysis of this and discovered that the Oracle Client libraries are the source of the slowdowns involved. @cjbj will follow up after we discuss this further internally. |
I created an Oracle bug / enhancement request 33023288 to track this. |
This issue has been automatically marked as inactive because it has not been updated recently. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not been updated for a month. |
Has there been any movement on that request? |
@GertBurger no! |
@GertBurger You mentioned the IN clause case before. Check the newish example in Binding Multiple Values to a SQL WHERE IN Clause. This will give you just one bind variable for a large number of values:
then the application could do:
|
LOL. I've updated my earlier comment with an example in the correct programming language. |
As the number bind variables increase, the more time is spent in
libclntsh.so
prior to the query being sent to the server. The relationship between number of bind variables and time taken is super linear and gets pretty slow.On my machine a query with 60k parameters take close to 20secs, the same query via postgresql/psycopg2 takes 400msec.
Is this an oracle client issue? Am I doing something wrong? Is cx_Oracle doing something wrong?
So far I have only tested this with selects and only as part of IN conditions.
Profile:
Needs ipython for
%time
and a preexistingcursor
instance. You also need to provide a table name atYOUR_TABLE
. Any table with anID
column will work, preferably an empty table.The text was updated successfully, but these errors were encountered: