-
Notifications
You must be signed in to change notification settings - Fork 645
Use a temp table for encode_many #6
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
Conversation
Just using IN will be faster for small numbers of crates, so you might want to switch implementations depending on crates.len(). The best solution would be to use COPY, but I haven't implemented that yet. I haven't actually tested this, but it compiles!
let mut query = "INSERT INTO crateids (id) VALUES (".to_string(); | ||
let mut crateids: Vec<&ToSql> = vec![]; | ||
for (i, krate) in crates.iter().enumerate() { | ||
query.push_str(format!("${}", i+1).as_slice()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to build a query that looks like ... VALUES ($1$2$3...$n) ...
or should there be spaces/commas too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Derp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this could theoretically use a writer to avoid the format!
temporary strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed that as well, thanks
BTW, bad things will happen if |
For now that list should always be small enough (on the order of at most 100), so I don't think we need this quite yet. That being said, this is a pretty slick way to do thing that I've never heard of before! I'll be sure to remember this for later queries, thanks @sfackler! |
Bump to latest conduit alpha and use `http` types
Bump to latest conduit alpha and use `http` types
Bump to latest conduit alpha and use `http` types
Add support for changes to `conduit::Body`
Just using IN will be faster for small numbers of crates, so you might
want to switch implementations depending on crates.len(). The best
solution would be to use COPY, but I haven't implemented that yet.
I haven't actually tested this, but it compiles!