node-mysql2: node-mysql2 is running slower than node-mysql, config issue?

Hi, I wanted to try mysql2 as a replacement for mysql for performance reasons. When I tried it in a production environment, I am actually seeing that mysql2 is slower, so I wonder if it’s a config issue on my end. Are there any settings I should try changing?

Using the profiler, I didn’t see anything out of the ordinary. The vast majority of time is spent in handlePacket -> TextRow -> wrap. The only other difference I notice between the two libraries is that mysql2 seems to invoke Readable.push in a very regular frequency time-wise, whereas mysql does it in an irregular pattern. Thank you!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 26 (26 by maintainers)

Most upvoted comments

I generated it using https://www.mockaroo.com/

I found a couple issues with it. It seems to be much slower due to

  1. “typeCast” code handling where it has a compatibility layer that adds a lot of overhead due to the request to just-in-time parsing of column definition’s properties (see #889)
  2. the state management + some code generation seems to make the code optimization not working as expected

For the first one, I can fix it by caching column definition attribute.