Open kswope opened 2 years ago
Because node-mysql2 is "with focus on performance" (as first sentence in its readme). It generates JS code per query at runtime for parser performance. So it's no surprise that deno-mysql is 7x slower.
That's fine and I appreciate it, but I'm getting 8x to 10x slower. In my experience that's a sign something is wrong.
I should add I'm getting 10x worse performance from queries that return large data sets, which would indicate its not the upfront parsing costs at all but the problem is maybe more likely how results from the db are being processed.
how results from the db are being processed
It's what their generated JS code do, which read and parse result rows from the db.
I added a mysql version (not mysql2) in the form of promise-mysql.
Its entirely possible that this benchmark is not benchmarking the right thing and I screwed something up (it just uses console.time, nothing fancy), but I tried to keep the code identical (allowing for driver differences), and I'm still seeing something noteworthy
Here's a snippet of whats over at the benchmark repo
bash-3.2$ node node/index.js # using promise-mysql
time: 1.115s
bash-3.2$ node node/index2.js # using mysql2
time: 745.972ms
bash-3.2$ deno run --allow-net ./deno/index.ts
time: 7064ms
I was getting much worse performance than node/mysql2 in a web app benchmarked by k6. The problem seemed to be this driver, so I made a crude benchmark which seems to agree with what I was seeing.
https://github.com/kswope/deno-mysql-bench
Here's a preview of the kind of results I'm getting