Skip to content

Emit an event after submitting the query. - #1563

Closed
emilsedgh wants to merge 1 commit into
brianc:masterfrom
emilsedgh:master
Closed

Emit an event after submitting the query.#1563
emilsedgh wants to merge 1 commit into
brianc:masterfrom
emilsedgh:master

Conversation

@emilsedgh

@emilsedgh emilsedgh commented Jan 24, 2018

Copy link
Copy Markdown

Makes it possible to profile queries.
Fixes #874

If this event is emitted, then anyone who wants can profile their queries by comparing the time of this and the first row returned. like this:

let submit_time, response_time

query.on('submit', () => {
   submit_time = process.hrtime()
})

query.once('row', () => {
  response_time = process.hrtime(submit_time)
  const [seconds, nanoseconds] = process.hrtime(submit_time)
  const elapsed = Math.round((seconds * 1000) + (nanoseconds * 1e-6))
  console.log(`Elapsed: ${elapsed}`)
})

Makes it possible to profile queries.
Fixes brianc#874
@emilsedgh

Copy link
Copy Markdown
Author

This isn't useful for the mentioned purpose as the row event isn't fired if there are no rows.

I'll revisit.

@emilsedgh emilsedgh closed this Jan 25, 2018
@dt-rush

dt-rush commented Nov 15, 2018

Copy link
Copy Markdown

@emilsedgh is there any reason why we couldn't listen for 'end'?

@neongreen

Copy link
Copy Markdown

@emilsedgh have you found a way to get query durations after all? I've stumbled upon the same issue.

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

Successfully merging this pull request may close these issues.

Time queries?

3 participants