pentagon icon indicating copy to clipboard operation
pentagon copied to clipboard

Query performance is slow with larger amount of items

Open skoshx opened this issue 1 year ago • 7 comments

With about 7000 items, an API GET request with a findMany() query takes about 8 seconds. The duration of the query (linearly?) correlates with the amount of items.

skoshx avatar Jun 26 '23 20:06 skoshx

Might be a good idea to add some benchmarks that run in CI with deno bench for different amount of items and scenarios.

jnssnmrcs avatar Jun 27 '23 17:06 jnssnmrcs

Yeah, that was definitely the intention, just haven't gotten around to doing so... And it wasn't a super high priority as I didn't notice any performance problems, but now my OG Image generation is taking 8 seconds and that is untenable so will have to prioritize this haha :D

skoshx avatar Jun 28 '23 22:06 skoshx

Quite fruitless efforts, running benchmarks on my local machine atleast, with 10,000 items, I'm getting p995 times of 24 microseconds on findFirst & findMany… Will need to do some different kind of benchmarking to understand why it's being so slow in production.

skoshx avatar Jun 30 '23 22:06 skoshx

For posterity; benchmark was written late at night and as such it was incorrect, here are the real results:

🍔 Created 10000 mock double cheeseburger orders. cpu: Apple M2 Pro runtime: deno 1.34.1 (aarch64-apple-darwin)

file:///Users/rasmus/Desktop/DEV/Web/pentagon/bench/crud_bench.ts benchmark time (avg) (min … max) p75 p99 p995


findFirst > where 40.17 ms/iter(37.89 ms … 42.32 ms) 41.57 ms 42.32 ms 42.32 ms findMany 42.07 ms/iter(39.83 ms … 45.69 ms) 43.25 ms 45.69 ms 45.69 ms findMany > where 43.29 ms/iter(41.57 ms … 45.03 ms) 44.29 ms 45.03 ms 45.03 ms findMany > where & include 99.47 ms/iter(96.27 ms … 103.38 ms) 100.88 ms 103.38 ms 103.38 ms

include causes major performance hit.

skoshx avatar Jul 01 '23 12:07 skoshx

The latest 0.2.1 release no longer has performance problems (aside from include being about 2x slower), so closing for now.

skoshx avatar Jul 18 '23 11:07 skoshx

The latest 0.2.1 release no longer has performance problems (aside from include being about 2x slower), so closing for now.

Version 0.2.1 does not exist yet on deno x

waptik avatar Jul 18 '23 20:07 waptik

With a large amount of items, there's performance problems on the edge. Will have to investigate whether it's because of Pentagon's bad implementation or something on Deno KV's end.

skoshx avatar Aug 20 '23 08:08 skoshx