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

Query slow using positional bindings against varchar columns #182

Open
sax opened this issue Sep 19, 2024 · 1 comment
Open

Query slow using positional bindings against varchar columns #182

sax opened this issue Sep 19, 2024 · 1 comment

Comments

@sax
Copy link
Contributor

sax commented Sep 19, 2024

I've been finding that queries to Oracle 11g wind up very slow when using query or query! with parameters defined via positional bindings like :1. Today I found this:

https://stackoverflow.com/questions/37784388/slow-with-bind-parameters-even-slower-with-jdbctemplate#comment121142811_38078671

I think we're hitting this... the database has varchar columns, meaning that our queries are skipping indexes and scanning the table to convert each matched column to nvarchars. When we explicitly to_char(:1), our query speeds up dramatically.

Is there a possible connection configuration that would help? Maybe specify the default string parameter type as varchar?

If not hopefully we can contribute something. Just wondering if anyone already has a solution.

@vstavskyi
Copy link
Member

In jdbc

short defaultFormOfUse = 1;
if (this.connection.defaultnchar)
  defaultFormOfUse = 2; 

In erlang

(encode_sb4(Charset))/binary, %character set id
case Charset of %character set form
?AL16UTF16_CHARSET -> 2;
_ -> 1
end,

To set UTF8 and FORM_CHAR, replace with this code

    (encode_sb4(?AL32UTF8_CHARSET))/binary,
    1,

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

2 participants