-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Regression in v0.6.0 when using an INSERT ... RETURNING
clause with SQLite
#1921
Comments
cc @tyrelr who worked on the refactors to SQLite, sounds like some unintentional exponential blowup. |
I went ahead and gathered a And here's the output of |
Thanks for the perf results. The call to logger.add_result is hashing a Vec<(i64, String, i64, i64, i64, Vec)>, which is also cloned. So that large struct acting as a hash-key is probably the root issue. I see a few ways to improve performance of that:
I was hoping to use the logging to see how many end-to-end paths to ResultRow commands are found. But, I haven't convinced cargo/sqlx-cli to show me the logs from running explain. Hopefully I'll have some time to look closer on the weekend. |
After playing with the code for a bit, this looks like a combination of a HUGE number of potential unique paths, exacerbating the inefficient logging code. On my machine I can see these numbers when I run the reproducer:
I've run out of time for now, so haven't figured out how many execution paths were kept vs. pruned by merged path detection, nor measured the timing of combining the 2 approaches. |
Update to 0.6.1 isn't possible right now due to massive increase in compile time and memory usage. The core build uses 30GB after a few minutes! With 0.5.13 the build takes less than a minute and < 2GB. See launchbadge/sqlx#1921 Possible fix with launchbadge/sqlx#1946
There was a fix PR opened in #1946 but I'm still waiting for response from the author. |
As far as I can tell the fix is included in 0.7.0, should this be closed? |
I can't reproduce the issue with 0.7.0, so it seems like this is fixed. |
Compiling a non-trivial
INSERT
query that contains aRETURNING
clause results in long compile times, with very high memory consumption.I've created an example repository which demonstrates the issue: jaehl/sqlx-bug
With v0.6.0 that project compiles on my machine in 100 seconds (and using 7GB of memory). With v0.5.13 it compiles in about 150 milliseconds.
First bad commit appears to be ed56622 (more specifically it seems to be this commit from the PR: e5a5e36).
The text was updated successfully, but these errors were encountered: