-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: statement with parameters much slower than with string concatenation #21463
Comments
Hi @sahlex, thanks for the report. If possible, could you please share the relevant portion of your database schema? Other useful output would be running |
Hi @jordanlewis . Please find attached the relevant part of the schema and the query plan.
|
Thanks. Taking a look at this. |
I notice that |
select count(1) from rights; |
Closing this due to inactivity (on our part). That being said, since Jan 2018 we've implemented a whole new SQL planner, a cost-based optimizer, that likely doesn't suffer from the problem that we were talking about here (as I'm guessing the issue here was a planner one). Please feel free to re-open this if you still see this behavior on a newer version of CockroachDB, and sorry we never got to it. |
Cockroach version:
I'm using hibernate (5.2.10) together with cockroachdb for a proof-of-concept. While re-writing some queries from mysql to postgres/crdb I noticed a weird behavior. While calling crdb with a native query which I optimized in DBeaver (takes about 20ms) I used parameters in the query using hibernate like this:
This query took almost 5 seconds! However, when I put the parameters directly into the statement using string concatenation it's fast again.
I would have expected the query with the parameters to take the same time (approx) to what I observed in DBeaver.
See also discussion in https://forum.cockroachlabs.com/t/prepared-statement-slower-than-string-concatenated-query/1280/3
The text was updated successfully, but these errors were encountered: