Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting terrible performance. I must be doing something wrong. #125

Open
kswope opened this issue Jan 15, 2022 · 5 comments
Open

Getting terrible performance. I must be doing something wrong. #125

kswope opened this issue Jan 15, 2022 · 5 comments

Comments

@kswope
Copy link

kswope commented Jan 15, 2022

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

deno-mysql-bench> deno run --allow-net ./deno/index.ts
INFO connecting localhost:3306
INFO connected to localhost:3306
default: 7402ms
INFO close connection

deno-mysql-bench> node node/index.js
default: 996.609ms

@lideming
Copy link
Collaborator

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.

@kswope
Copy link
Author

kswope commented Jan 17, 2022

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.

@kswope
Copy link
Author

kswope commented Jan 17, 2022

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.

@lideming
Copy link
Collaborator

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.

@kswope
Copy link
Author

kswope commented Jan 18, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants