Hi, after working on quite some Rust backends (with axum) using diesel (through `deadpool_diesel`

) or sqlx I've experienced the following things:

- I quite like writing raw SQL (or use a query builder for dynamic queries) because for me it's easier to understand what exactly is going on (especially for complex queries with a lot of joins)
- With
`diesel`

I experienced build times to increase as the project grows (the largest project has a separate library crate that contains all database related code and this library alone takes ~90s to compile)

My first question is, if someone also noticed long build times with `diesel`

and can give an insight on how the problem could possibly be solved.

Apart from that I had a pretty wild idea :

As `sqlx`

pretty much fits my needs but it's lagging behind `diesel`

in terms of performance (see `diesel`

metrics and my own benchmark below) I thought about using `diesel`

but without its DSL and therefore being able to remove all of the derive and proc macros (which maybe cause slow compile times). I'd then use `diesel`

to execute raw queries or build dynamic queries with `diesel`

's query builder.

What do you think about this idea? Does this make any sense or would you recommend using alternative crates? Would this approach maybe even make `diesel`

queries to perform worse?

## my benchmark results

The following benchmarks were performed using `bombardier`

to create a lot of HTTP requests against a very minimal `axum`

backend which used `deadpool-diesel`

or `sqlx`

to execute trivial `select`

queries on the database. These backends were build in separate crates.

The `-c`

flag sets the number of connections and the `-n`

flag defines the number of requests to perform.

## `deadpool-diesel`

```
-------------------------------------------------------------------------------
Deadpool-Diesel (pool size = 10):
--- 10 connections ---
./bombardier -c 10 -n 100000 http://localhost:3000
Statistics Avg Stdev Max
Reqs/sec 6838.80 726.44 12961.47
Latency 1.46ms 196.07us 5.79ms
HTTP codes:
1xx - 0, 2xx - 100000, 3xx - 0, 4xx - 0, 5xx - 0
others - 0
Throughput: 1.19MB/s
--- 100 connections ---
./bombardier -c 100 -n 100000 http://localhost:3000
Statistics Avg Stdev Max
Reqs/sec 7605.17 713.38 16579.55
Latency 13.18ms 1.56ms 74.20ms
HTTP codes:
1xx - 0, 2xx - 100000, 3xx - 0, 4xx - 0, 5xx - 0
others - 0
Throughput: 1.31MB/s
--- 1.000 connections ---
./bombardier -c 1000 -n 100000 http://localhost:3000
Statistics Avg Stdev Max
Reqs/sec 7562.66 921.31 19251.22
Latency 133.00ms 62.76ms 1.47s
HTTP codes:
1xx - 0, 2xx - 100000, 3xx - 0, 4xx - 0, 5xx - 0
others - 0
Throughput: 1.30MB/s
--- 10.000 connections ---
./bombardier -c 10000 -n 100000 http://localhost:3000
Statistics Avg Stdev Max
Reqs/sec 7497.86 2817.29 76722.83
Latency 1.30s 0.90s 9.17s
HTTP codes:
1xx - 0, 2xx - 100000, 3xx - 0, 4xx - 0, 5xx - 0
others - 0
Throughput: 1.27MB/s
-------------------------------------------------------------------------------
```

## sqlx

```
-------------------------------------------------------------------------------
Sqlx (pool size = 10):
--- 10 connections ---
./bombardier -c 10 -n 100000 http://localhost:3000
Statistics Avg Stdev Max
Reqs/sec 6056.48 488.28 7226.05
Latency 1.65ms 224.14us 7.99ms
HTTP codes:
1xx - 0, 2xx - 100000, 3xx - 0, 4xx - 0, 5xx - 0
others - 0
Throughput: 1.05MB/s
--- 100 connections ---
./bombardier -c 100 -n 100000 http://localhost:3000
Statistics Avg Stdev Max
Reqs/sec 6127.51 496.42 7175.71
Latency 16.37ms 2.57ms 107.63ms
HTTP codes:
1xx - 0, 2xx - 100000, 3xx - 0, 4xx - 0, 5xx - 0
others - 0
Throughput: 1.06MB/s
--- 1.000 connections ---
./bombardier -c 1000 -n 100000 http://localhost:3000
Statistics Avg Stdev Max
Reqs/sec 6139.28 829.31 22694.44
Latency 163.64ms 54.06ms 1.47s
HTTP codes:
1xx - 0, 2xx - 100000, 3xx - 0, 4xx - 0, 5xx - 0
others - 0
Throughput: 1.05MB/s
--- 10.000 connections ---
./bombardier -c 10000 -n 100000 http://localhost:3000
Statistics Avg Stdev Max
Reqs/sec 5745.57 709.37 10201.69
Latency 1.68s 1.46s 14.48s
HTTP codes:
1xx - 0, 2xx - 100000, 3xx - 0, 4xx - 0, 5xx - 0
others - 0
Throughput: 1.00MB/s
-------------------------------------------------------------------------------
```