sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Place a query fingerprint in a comment at the start of each query

Open grahamc opened this issue 2 months ago • 1 comments

I have found these related issues/pull requests

I don't see any related issues or pull requests.

Description

I'm finding that various DB performance tools don't show me the whole query. In particular, this is true for RDS. This makes it hard to identify which query is slow. To help this, we've manually injected a uuid in a comment on all queries:

sqlx::query_scalar!(
                r#"
                -- 935300b8-3def-431f-8480-8ae8e034fb0a
                SELECT
                    customer.name
...

This seems fine in the sense that it solves the problem, but the diff to apply it was hefty and tedious (+4,261 -3,752).

Prefered solution

Instead, I'd love for sqlx to automatically inject an identifying hash (for example, the hash of the query string) as a comment prefix. This would let us search .sqlx/query-*.json for the matching hash and conclusively identify the query.

Is this a breaking change? Why or why not?

It will cause all the pregenerated / stored .json query documents to change.

grahamc avatar Nov 10 '25 19:11 grahamc

See also #1697

abonander avatar Nov 11 '25 17:11 abonander