Tracing query performance with Knex.js
Tracing query performance with Knex.js
Over the years, I found myself searching for the same exact problem whenever I was using Knex.js, the query planner for Node.js. Since, the following code snippet is small enough to not be a Node library, I’m intrigued to share this as a blog post.
Initially, a blog post from Atomic Object proposed to use query
and query-response
events on the knex.js instance, since it’s also an event emitter, but I guess it’s time to use perf_hooks and properly mark the performance of a query using the native tooling.
Small snippet using perf_hooks
With the following code, we’ll see the following code on our terminal.