We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
RETURNING
The following query, when used with query_scalar!, takes a very long time to compile.
query_scalar!
INSERT INTO users (username, password_hash) VALUES (?, ?) RETURNING id
On my laptop, this takes 39.6 seconds to compile. If I remove the RETURNING clause, then it takes 1.1 seconds.
Also, rustc uses 1.8 GB of memory, which I don't think is normal.
git clone https://github.com/j-tai/sqlx-repro
cd sqlx-repro
sqlite3 db.sqlite '.read dump.sql'
cargo build
src/main.rs
EXPLAIN
sqlite> EXPLAIN INSERT INTO users (username, password_hash) VALUES (?, ?) RETURNING id; addr opcode p1 p2 p3 p4 p5 comment ---- ------------- ---- ---- ---- ------------- -- ------------- 0 Init 0 31 0 0 Start at 31 1 OpenWrite 0 2 0 5 0 root=2 iDb=0; users 2 OpenWrite 1 3 0 k(1,) 0 root=3 iDb=0; sqlite_autoindex_users_1 3 SoftNull 2 0 0 0 r[2]=NULL 4 Variable 1 3 0 0 r[3]=parameter(1,) 5 Variable 2 4 0 0 r[4]=parameter(2,) 6 Function 0 0 5 current_timestamp(0) 0 r[5]=func() 7 NewRowid 0 1 0 0 r[1]=rowid 8 HaltIfNull 1299 2 3 users.username 1 if r[3]=null halt 9 HaltIfNull 1299 2 4 users.password_hash 1 if r[4]=null halt 10 HaltIfNull 1299 2 5 users.created 1 if r[5]=null halt 11 HaltIfNull 1299 2 6 users.privacy 1 if r[6]=null halt 12 Affinity 2 5 0 DBBCC 0 affinity(r[2..6]) 13 Noop 0 0 0 0 prep index sqlite_autoindex_users_1 14 SCopy 3 8 0 0 r[8]=r[3]; username 15 IntCopy 1 9 0 0 r[9]=r[1]; rowid 16 MakeRecord 8 2 7 0 r[7]=mkrec(r[8..9]); for sqlite_autoindex_users_1 17 NoConflict 1 19 8 1 0 key=r[8] 18 Halt 2067 2 0 users.username 2 19 MakeRecord 2 5 10 0 r[10]=mkrec(r[2..6]) 20 IdxInsert 1 7 8 1 16 key=r[7] 21 Insert 0 10 1 users 57 intkey=r[1] data=r[10] 22 SCopy 1 12 0 0 r[12]=r[1] 23 MakeRecord 12 1 13 0 r[13]=mkrec(r[12]) 24 NewRowid 3 14 0 0 r[14]=rowid 25 Insert 3 13 14 0 intkey=r[14] data=r[13] 26 Rewind 3 30 0 0 27 Column 3 0 12 0 r[12]= 28 ResultRow 12 1 0 0 output=r[12] 29 Next 3 27 0 0 30 Halt 0 0 0 0 31 Transaction 0 1 10 0 1 usesStmtJournal=1 32 Integer 0 6 0 0 r[6]=0 33 OpenEphemeral 3 1 0 0 nColumn=1 34 Goto 0 1 0 0
rustc --version
The text was updated successfully, but these errors were encountered:
Duplicate of #1921
There's a fix in #1946, was waiting on a response from the author.
Sorry, something went wrong.
Thanks. Did a lot of searches and somehow didn't find that.
No branches or pull requests
Bug Description
The following query, when used with
query_scalar!
, takes a very long time to compile.On my laptop, this takes 39.6 seconds to compile. If I remove the
RETURNING
clause, then it takes 1.1 seconds.Also, rustc uses 1.8 GB of memory, which I don't think is normal.
Minimal Reproduction
git clone https://github.com/j-tai/sqlx-repro
cd sqlx-repro
sqlite3 db.sqlite '.read dump.sql'
(create the database, this is necessary to reproduce)cargo build
→ Compiling the sqlx-repro crate takes a very long time.
src/main.rs
(e.g., add a comment or something)cargo build
→ Compiling takes a very long time again.
Output of
EXPLAIN
Info
rustc --version
: rustc 1.63.0 (4b91a6ea7 2022-08-08)The text was updated successfully, but these errors were encountered: