Something lightweight and fast? Please no SQLx or Diesel.
May I ask what's stopping you from using SQLx? You can simply refrain from performing any object relational mapping. The library is perfectly built for executing your own SQL commands directly to the database of your choice asynchronously, with a runtime such as Tokio: By enabling the runtime-tokio
feature flag for SQLx.
If you are looking for a fast SQL library you should really consider using plain diesel, as it's currently the most performant solution according to the linked set of benchmarks. In an async context you are OK with using diesel through an async connection pool like deadpool-diesel
, as your are usually restricted on the number of database connections anyway. (That solution seems to be ~20% more performant that sqlx as shown by that post). If you believe for whatever reason that you need a fully async solution you can use diesel-async
.
While diesel provides some ORM like features, you don't need to use them.
Could you explain the async solution in deadpool-async
vs the "fully" async solution provided by diesel-async
? I understand deadpool-async
provides pooling through deadpool
which is async but what exactly is the difference?
Thank's for linking to my topic @weiznich. I just added my benchmark results and some other findings as "closing words" to it.
@feelingsonice You might be interested in the benchmark results and how diesel_async
compares to diesel
+ deadpool
deadpool-diesel
provides an async pool implementation but uses sync diesel internally. It offers an API that enforces that your database queries run in a spawn_blocking
task and it internally uses essentially an async mutex to protext the pool on checkout/checkin.
diesel-async
is a from scratch rust implementation that provides a completly async rust database driver for postgresql and mysql, compared to the "normal" libpq/libmysqlclient based drives used by "normal" diesel. (There is also support for deadpool
in diesel-async
, which then does not use spawn_blocking
as that's not required anymore)