One option is to use the standard Express.js logging mechanism:
Shortcut:
DEBUG='sequelize:sql:*' npm run dev
npm run devs
These logs also include some kind of timing information. However, we are not entirely sure that the timings mean, as they show for both
The meaning of
Executing
(query is about to start) and Executed
(query finished) lines with possibly different values e.g.:
sequelize:sql:pg Executing (default): SELECT 1+1 AS result +0ms
sequelize:sql:pg Executed (default): SELECT 1+1 AS result +1ms
+0ms
and +1ms
appears to be the timing since last the last message with the same ID, i.e. sequelize:sql:pg
in this case. Therefore, so long as there wasn't any sequelize:sql:pg
between and the corresponding Executing
, the Executing
timing should give us the query time.This is a bit messy however, as we often want to find the largest numbers for profiling, and there could be a large time delta during inactivity.