Skip to content
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

Always enforce type-safety on sqlx queries #15

Open
qsantos opened this issue Dec 27, 2023 · 2 comments
Open

Always enforce type-safety on sqlx queries #15

qsantos opened this issue Dec 27, 2023 · 2 comments

Comments

@qsantos
Copy link
Owner

qsantos commented Dec 27, 2023

Using non-macro sqlx::query does not enforce type safety. However, the macro seems to not allow for zero-copy decoding.

@qsantos
Copy link
Owner Author

qsantos commented Jan 6, 2024

There is currently no official zero-copy decoding in sqlx. However, switching to String for all the fields and using String everywhere reduces performance significantly.

In the current approach, row iteration actually performs no significant allocation and only checks that the strings are valid UTF-8:

Screenshot 2024-01-06 at 20-39-20 _target_release_nhkeasier – 06_01_2024 19 35 45 UTC – Firefox Profiler

Switching to the query_as! macro clearly shows that fields are being copied to new buffers in addition to being validated as UTF-8:
Screenshot 2024-01-06 at 20-39-27 _target_release_nhkeasier – 06_01_2024 19 30 26 UTC – Firefox Profiler

@qsantos
Copy link
Owner Author

qsantos commented Jan 6, 2024

So, this issue is basically blocked by launchbadge/sqlx#2661.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant