Currently prepared queries are using references, and store a lot of data in ETS. In SQL we take a different approach to identify queries, we have globally unique ids, which are generated at compile time. I could imagine a world where the only information needed to be stored would be the conn pid and id to signify that the query has been prepared in the specific connection or needed to be prepared.To be clear, I'm not asking anyone to do this work, I can do it myself. But I want to gauge the core team if this kind of improvement is of intrest to them.
--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/elixir-ecto/73b679f1-49e3-411d-a9d5-43fcf71aec18n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/elixir-ecto/84ab3ed7-f6d9-4b19-8fe0-50608939f0can%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/elixir-ecto/3327cc3e-ba96-4484-86c9-e50c2fdc29e3n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/elixir-ecto/697a86e5-3d63-4abc-a165-5d9269b168efn%40googlegroups.com.

Now we have linear scaling of the pool, I've included an Ecto benchmark as well.
➜ sql git:(main) ✗ mix sql.bench.pool
🧠 SQL.Pool Live Benchmark | Concurrency: 40 | Scheduler Online: 10 | Scheduler: 10 | Total Queries: 46077 | QPS: 3125.0 | Total dead: 0 | Error Rate: 0.0% | Retry Rate: 0.0%
Time left: 0 s
Pool Size: Initial: 20 | Current: 20 | Recommended: 16 | Active: 20 | Idle: 0 | Dead: 0
λ (pool): 3125.0 req/s: ▆▆▆▇▇▆▆▇▇▇▆▇▇▇▆▆▆▆▆▆▇▇▇▆▇▇▇▆▇▆▇▇▇▇▆▇▇▆▇▇▇▇▇▆█▇▇▇▆▇
W: 6.0 ms: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇█▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
L: 20 connections (recommended: 16): ██████████████████████████████████████████████████
Error Rate: 0.0% ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
Retry Rate: 0.0% ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
── Per-schedule utilization ─────────────
1: ██████████ 10%
↳ 2: ██████████████████████████████████████████████████ 99% (alive)
↳ 1: ██████████████████████████████████████████████████ 98% (alive)
2: ██████████ 10%
↳ 4: ██████████████████████████████████████████████████ 99% (alive)
↳ 3: ██████████████████████████████████████████████████ 99% (alive)
3: ██████████ 10%
↳ 6: ██████████████████████████████████████████████████ 99% (alive)
↳ 5: ██████████████████████████████████████████████████ 97% (alive)
4: ██████████ 10%
↳ 8: ██████████████████████████████████████████████████ 99% (alive)
↳ 7: ██████████████████████████████████████████████████ 98% (alive)
5: ██████████ 10%
↳ 9: ██████████████████████████████████████████████████ 98% (alive)
↳ 10: ██████████████████████████████████████████████████ 98% (alive)
6: ██████████ 10%
↳ 12: ██████████████████████████████████████████████████ 99% (alive)
↳ 11: ██████████████████████████████████████████████████ 97% (alive)
7: ██████████ 10%
↳ 14: ██████████████████████████████████████████████████ 100% (alive)
↳ 13: ██████████████████████████████████████████████████ 98% (alive)
8: ██████████ 10%
↳ 16: ██████████████████████████████████████████████████ 98% (alive)
↳ 15: ██████████████████████████████████████████████████ 98% (alive)
9: ██████████ 10%
↳ 17: ██████████████████████████████████████████████████ 97% (alive)
↳ 18: ██████████████████████████████████████████████████ 97% (alive)
10: ██████████ 10%
↳ 20: ██████████████████████████████████████████████████ 99% (alive)
↳ 19: ██████████████████████████████████████████████████ 96% (alive)
➜ sql git:(main) ✗ mix run /benchmarks/ecto.exs
🧠 SQL.Pool Live Benchmark | Concurrency: 40 | Total Queries: 22230 | QPS: 1566.7
Pool Size: Initial: 20
Time left: 0 s
➜ sql git:(main) ✗ mix run benchmarks/ecto.exs
Starting scaling benchmark (pool size: 40)
Clients: 1
Total requests: 803, Measured QPS: 160.6
Theoretical max QPS: 8.0e3
Clients: 2
Total requests: 1629, Measured QPS: 325.8
Theoretical max QPS: 8.0e3
Clients: 3
Total requests: 2441, Measured QPS: 488.2
Theoretical max QPS: 8.0e3
Clients: 4
Total requests: 3218, Measured QPS: 643.6
Theoretical max QPS: 8.0e3
Clients: 5
Total requests: 3999, Measured QPS: 799.8
Theoretical max QPS: 8.0e3
Clients: 6
Total requests: 4913, Measured QPS: 982.6
Theoretical max QPS: 8.0e3
Clients: 7
Total requests: 5728, Measured QPS: 1145.6
Theoretical max QPS: 8.0e3
Clients: 8
Total requests: 6533, Measured QPS: 1306.6
Theoretical max QPS: 8.0e3
Clients: 9
Total requests: 7311, Measured QPS: 1462.2
Theoretical max QPS: 8.0e3
Clients: 10
Total requests: 8152, Measured QPS: 1630.4
Theoretical max QPS: 8.0e3
Clients: 11
Total requests: 8084, Measured QPS: 1616.8
Theoretical max QPS: 8.0e3
Clients: 12
Total requests: 8193, Measured QPS: 1638.6
Theoretical max QPS: 8.0e3
Clients: 13
Total requests: 8095, Measured QPS: 1619.0
Theoretical max QPS: 8.0e3
Clients: 14
Total requests: 8145, Measured QPS: 1629.0
Theoretical max QPS: 8.0e3
Clients: 15
Total requests: 8182, Measured QPS: 1636.4
Theoretical max QPS: 8.0e3
Clients: 16
Total requests: 7884, Measured QPS: 1576.8
Theoretical max QPS: 8.0e3
Clients: 17
Total requests: 7966, Measured QPS: 1593.2
Theoretical max QPS: 8.0e3
Clients: 18
Total requests: 7510, Measured QPS: 1502.0
Theoretical max QPS: 8.0e3
Clients: 19
Total requests: 8055, Measured QPS: 1611.0
Theoretical max QPS: 8.0e3
Clients: 20
Total requests: 8104, Measured QPS: 1620.8
Theoretical max QPS: 8.0e3
Clients: 21
Total requests: 8125, Measured QPS: 1625.0
Theoretical max QPS: 8.0e3
Clients: 22
Total requests: 8132, Measured QPS: 1626.4
Theoretical max QPS: 8.0e3
Clients: 23
Total requests: 8079, Measured QPS: 1615.8
Theoretical max QPS: 8.0e3
Clients: 24
Total requests: 8107, Measured QPS: 1621.4
Theoretical max QPS: 8.0e3
Clients: 25
Total requests: 8130, Measured QPS: 1626.0
Theoretical max QPS: 8.0e3
Clients: 26
Total requests: 7683, Measured QPS: 1536.6
Theoretical max QPS: 8.0e3
Clients: 27
Total requests: 7894, Measured QPS: 1578.8
Theoretical max QPS: 8.0e3
Clients: 28
Total requests: 8015, Measured QPS: 1603.0
Theoretical max QPS: 8.0e3
Clients: 29
Total requests: 8062, Measured QPS: 1612.4
Theoretical max QPS: 8.0e3
Clients: 30
Total requests: 8024, Measured QPS: 1604.8
Theoretical max QPS: 8.0e3
Clients: 31
Total requests: 7965, Measured QPS: 1593.0
Theoretical max QPS: 8.0e3
Clients: 32
Total requests: 7837, Measured QPS: 1567.4
Theoretical max QPS: 8.0e3
Clients: 33
Total requests: 8025, Measured QPS: 1605.0
Theoretical max QPS: 8.0e3
Clients: 34
Total requests: 8064, Measured QPS: 1612.8
Theoretical max QPS: 8.0e3
Clients: 35
Total requests: 8077, Measured QPS: 1615.4
Theoretical max QPS: 8.0e3
Clients: 36
Total requests: 8191, Measured QPS: 1638.2
Theoretical max QPS: 8.0e3
Clients: 37
Total requests: 8104, Measured QPS: 1620.8
Theoretical max QPS: 8.0e3
Clients: 38
Total requests: 8138, Measured QPS: 1627.6
Theoretical max QPS: 8.0e3
Clients: 39
Total requests: 8103, Measured QPS: 1620.6
Theoretical max QPS: 8.0e3
Clients: 40
Total requests: 8223, Measured QPS: 1644.6
Theoretical max QPS: 8.0e3
Clients: 41
Total requests: 8178, Measured QPS: 1635.6
Theoretical max QPS: 8.0e3
Clients: 42
Total requests: 8196, Measured QPS: 1639.2
Theoretical max QPS: 8.0e3
Clients: 43
Total requests: 8176, Measured QPS: 1635.2
Theoretical max QPS: 8.0e3
Clients: 44
Total requests: 8107, Measured QPS: 1621.4
Theoretical max QPS: 8.0e3
Clients: 45
Total requests: 8186, Measured QPS: 1637.2
Theoretical max QPS: 8.0e3
Clients: 46
Total requests: 8247, Measured QPS: 1649.4
Theoretical max QPS: 8.0e3
Clients: 47
Total requests: 7920, Measured QPS: 1584.0
Theoretical max QPS: 8.0e3
Clients: 48
Total requests: 8057, Measured QPS: 1611.4
Theoretical max QPS: 8.0e3
Clients: 49
Total requests: 8159, Measured QPS: 1631.8
Theoretical max QPS: 8.0e3
Clients: 50
Total requests: 8123, Measured QPS: 1624.6
Theoretical max QPS: 8.0e3
➜ sql git:(main) ✗ mix sql.bench.pool
Starting scaling benchmark (pool size: 40)
Clients: 1
Total requests: 824, Measured QPS: 164.8
Theoretical max QPS: 8.0e3
Clients: 2
Total requests: 1645, Measured QPS: 329.0
Theoretical max QPS: 8.0e3
Clients: 3
Total requests: 2439, Measured QPS: 487.8
Theoretical max QPS: 8.0e3
Clients: 4
Total requests: 3216, Measured QPS: 643.2
Theoretical max QPS: 8.0e3
Clients: 5
Total requests: 4092, Measured QPS: 818.4
Theoretical max QPS: 8.0e3
Clients: 6
Total requests: 4860, Measured QPS: 972.0
Theoretical max QPS: 8.0e3
Clients: 7
Total requests: 5691, Measured QPS: 1138.2
Theoretical max QPS: 8.0e3
Clients: 8
Total requests: 6480, Measured QPS: 1296.0
Theoretical max QPS: 8.0e3
Clients: 9
Total requests: 7392, Measured QPS: 1478.4
Theoretical max QPS: 8.0e3
Clients: 10
Total requests: 8150, Measured QPS: 1630.0
Theoretical max QPS: 8.0e3
Clients: 11
Total requests: 8960, Measured QPS: 1792.0
Theoretical max QPS: 8.0e3
Clients: 12
Total requests: 9816, Measured QPS: 1963.2
Theoretical max QPS: 8.0e3
Clients: 13
Total requests: 10645, Measured QPS: 2129.0
Theoretical max QPS: 8.0e3
Clients: 14
Total requests: 11074, Measured QPS: 2214.8
Theoretical max QPS: 8.0e3
Clients: 15
Total requests: 12024, Measured QPS: 2404.8
Theoretical max QPS: 8.0e3
Clients: 16
Total requests: 12816, Measured QPS: 2563.2
Theoretical max QPS: 8.0e3
Clients: 17
Total requests: 13665, Measured QPS: 2733.0
Theoretical max QPS: 8.0e3
Clients: 18
Total requests: 14515, Measured QPS: 2903.0
Theoretical max QPS: 8.0e3
Clients: 19
Total requests: 15588, Measured QPS: 3117.6
Theoretical max QPS: 8.0e3
Clients: 20
Total requests: 16295, Measured QPS: 3259.0
Theoretical max QPS: 8.0e3
Clients: 21
Total requests: 17256, Measured QPS: 3451.2
Theoretical max QPS: 8.0e3
Clients: 22
Total requests: 18348, Measured QPS: 3669.6
Theoretical max QPS: 8.0e3
Clients: 23
Total requests: 19182, Measured QPS: 3836.4
Theoretical max QPS: 8.0e3
Clients: 24
Total requests: 20016, Measured QPS: 4003.2
Theoretical max QPS: 8.0e3
Clients: 25
Total requests: 20850, Measured QPS: 4170.0
Theoretical max QPS: 8.0e3
Clients: 26
Total requests: 21684, Measured QPS: 4336.8
Theoretical max QPS: 8.0e3
Clients: 27
Total requests: 22518, Measured QPS: 4503.6
Theoretical max QPS: 8.0e3
Clients: 28
Total requests: 23352, Measured QPS: 4670.4
Theoretical max QPS: 8.0e3
Clients: 29
Total requests: 24186, Measured QPS: 4837.2
Theoretical max QPS: 8.0e3
Clients: 30
Total requests: 25020, Measured QPS: 5004.0
Theoretical max QPS: 8.0e3
Clients: 31
Total requests: 25854, Measured QPS: 5170.8
Theoretical max QPS: 8.0e3
Clients: 32
Total requests: 26688, Measured QPS: 5337.6
Theoretical max QPS: 8.0e3
Clients: 33
Total requests: 27522, Measured QPS: 5504.4
Theoretical max QPS: 8.0e3
Clients: 34
Total requests: 28356, Measured QPS: 5671.2
Theoretical max QPS: 8.0e3
Clients: 35
Total requests: 29190, Measured QPS: 5838.0
Theoretical max QPS: 8.0e3
Clients: 36
Total requests: 30024, Measured QPS: 6004.8
Theoretical max QPS: 8.0e3
Clients: 37
Total requests: 30747, Measured QPS: 6149.4
Theoretical max QPS: 8.0e3
Clients: 38
Total requests: 31692, Measured QPS: 6338.4
Theoretical max QPS: 8.0e3
Clients: 39
Total requests: 32526, Measured QPS: 6505.2
Theoretical max QPS: 8.0e3
Clients: 40
Total requests: 33360, Measured QPS: 6672.0
Theoretical max QPS: 8.0e3
Clients: 41
Total requests: 34194, Measured QPS: 6838.8
Theoretical max QPS: 8.0e3
Clients: 42
Total requests: 35028, Measured QPS: 7005.6
Theoretical max QPS: 8.0e3
Clients: 43
Total requests: 35862, Measured QPS: 7172.4
Theoretical max QPS: 8.0e3
Clients: 44
Total requests: 36696, Measured QPS: 7339.2
Theoretical max QPS: 8.0e3
Clients: 45
Total requests: 37530, Measured QPS: 7506.0
Theoretical max QPS: 8.0e3
Clients: 46
Total requests: 38360, Measured QPS: 7672.0
Theoretical max QPS: 8.0e3
Clients: 47
Total requests: 39197, Measured QPS: 7839.4
Theoretical max QPS: 8.0e3
Clients: 48
Total requests: 40030, Measured QPS: 8006.0
Theoretical max QPS: 8.0e3
Clients: 49
Total requests: 40862, Measured QPS: 8172.4
Theoretical max QPS: 8.0e3
Clients: 50
Total requests: 41694, Measured QPS: 8338.8
Theoretical max QPS: 8.0e3