SQLx Talk @ Svix SF Rust Meetup, 2025/12/04 #4124
abonander
started this conversation in
Announcements
Replies: 1 comment 2 replies
-
|
Note that you can directly link to a specific time by adding a query parameter of the timestamp measured in seconds: |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was recently invited by Svix to speak at their new Rust meetup hosted at their San Francisco office.
I talked about SQLx, giving a brief history, going over our current challenges and talking about plans for the near future.
The talk has been posted as a video on Svix's YouTube channel, along with talks from two other speakers (mine is from 00:00 to 33:26): https://www.youtube.com/watch?v=ZC7UcfBp2UQ
Slides: https://docs.google.com/presentation/d/151MAto59wZ5-0nRqrOTdnTmlr_ZvLgT9esjem41MQi0/edit?usp=sharing
Discuss on Reddit: https://www.reddit.com/r/rust/comments/1poilot/sqlx_talk_svix_sf_rust_meetup_20251204/?
Links, Notes, and Errata
About Me
rust-lang: hash: HashMap, custom key types, HashSet, and SmallIntMap rust-lang/rust-by-example#205#[proc_macro_attribute]rust-lang/rust#38842#[proc_macro]) rust-lang/rust#40129Reasons We Created SQLx
#[diagnostics]RFC by author of Diesel: The#[diagnostic]attribute namespace rust-lang/rfcs#3368tokio-dieselcreated by Ryan Leckey (@mehcode): https://crates.io/crates/tokio-dieseldiesel-asyncfirst-party async support for Diesel (0.1.0 released 2022/09/27): https://crates.io/crates/diesel-asyncCancellation: Rust's "Million-Dollar Mistake"?
asyncworks, including an example of howasyncis desugared: https://tokio.rs/tokio/tutorial/async#async-fn-as-a-futuretokio::sync::Notifyis a great example of how intrusive waitlists inasyncwork. It's used internally as a building-block for cross-task synchronization all throughout Tokio.async-stdis theevent-listenercrate, though it only becomes intrusive if you use thelistener!()macro, otherwise the nodes are heap-allocated.async/awaitecosystem was already aware of and took for granted, so there was little impetus to document it properly.std::panic::catch_unwind()(originallypanic::recover()) being made safe and the bounds added to it. To be fair, what the team was worried about was makingcatch_unwind()too easy to reach for as an error handling mechanism, so the API was deliberately designed to be annoying. However, the striking similarity between panic-safety and cancellation-safety, and the massive difference in concern about one over the other, was just something I wanted to point out.It's Actually a Feature, I Swear
AbortController: https://developer.mozilla.org/en-US/docs/Web/API/AbortControllerCancellationToken: https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=net-10.0context.WithCancel(): https://pkg.go.dev/context#example-WithCancelRST_STREAMframe at any time to cancel the request.tokio::time::timeout()cancels theFutureif the timeout elapses.tokio::select!()cancels the branches that haven't completed yet.tokio_util::sync::CancellationToken::run_until_cancalled()does exactly what it says on the tin.One of Many
ROLLBACKtransaction when dropped duringBEGIN. #39800.9.0-alpha.1releaseSolution: Spawn More Tasks
Null Safety from Thin Air
sqlx/sqlx-mysql/src/collation.rs
Lines 1 to 37 in e8384f2
The Lengths We Go to, to Not Parse SQL
RowDescriptionmessage.EXPLAINoutput in this method.I Dunno, Maybe Parsing SQL Would Be Easier
EXPLAINparsing for SQLite is in this file. This is code is especially arcane and difficult to maintain; I barely understand what's going on here, myself. It was originally written by @mehcode and only one or two other brave souls, namely @tyrelr, have dared to venture into that quagmire. One of the happiest days in my career will be the day I get to delete this file.It's Far from Perfect
sqlx::query!macros do not work with TimescaleDB Hyperfunctions due to query parts being optimized away #4019Lack of Interaction with
#[derive(FromRow)]FromRowtrait and derive: currently, the code generated by#[derive(FromRow)]looks up columns by name and type-check them for every single row, which is obviously a performance bottleneck. It's also completely unnecessary because the shape of the result-set is fixed once it starts coming in, so I want to separate this so one method looks up the column names and resolves them to offsets at the start of the result-set, and then another method uses those pre-resolved offsets to decode each row.What, Postgres Ain't Good Enough for You?
0.7.0release: Update: Our Plans Regarding MSSQL and Other Proprietary Drivers #1616sqlx-exasol: https://github.com/bobozaur/sqlx-exasol"SQLx is Slow?"
That Benchmark Cheats, Actually (Kinda)
tokio-postgres: https://github.com/TechEmpower/FrameworkBenchmarks/blob/R23/frameworks/Rust/axum/src/main_pg.rscommon::serve_hyper()is what starts the separate runtimes.unsafewhich used no synchronization because there was no cross-thread communication).tokio_postgres::Client) is a significant part of what makes this benchmark unrealistic, in my opinion. Any time you're doing more complex mutations, or you have a fetch coupled with a store, you should be using a transaction to have a coherent view of the data, e.g.: https://github.com/launchbadge/realworld-axum-sqlx/blob/f1b25654773228297e35c292f357d33b7121a101/src/http/profiles.rs#L101It's Not That Bad, Really
roa-diesel, which is the highest-scoring benchmark for them in Round 23. There is no framework namedroathat I could find in the source.R23tag for a fair comparison. It usesroa-dieselwhich wraps regular blocking calls with.spawn_blocking()instead of usingdiesel-async(which wasn't available yet when this benchmark was created, and it apparently was never updated).Rebuilding
sqlx::Poolfrom the Ground-Up (#3582)max_connections, so each shard essentially becomes a really inefficientMutexfor a single connection.asynccode, sinceperfwon't tell you how long a task was sitting at a.awaitpoint. There isn't a ton of advice or tools out there yet to help with this. I'd actually love to get some suggestions on how to approach this.Going into 2026
0.9.0-alpha.1: https://github.com/launchbadge/sqlx/blob/main/CHANGELOG.md#090-alpha1---2025-10-14Don't You Work for a Database Company, Now?
clickhouse-rs: Replace/supplement Serde serialization with bespoke traits ClickHouse/clickhouse-rs#336clickhouse-rs.clickhouse-rsand related internal projects is where I've spent most of my time lately. My arrangement with ClickHouse is similar to previous employers: I can work on SQLx as time permits, but there isn't really any dedicated time blocked out for it. I'm hoping that asclickhouse-rsstabilizes and the future SQLx ClickHouse driver shows a return in investment, that I'll be given dedicated time to work on it.Q&A
#rust!): clickhouse.com/slackBeta Was this translation helpful? Give feedback.
All reactions