Measure Query Execution Time

influxdb
#1

Im a recent convert to InfluxDB so sorry if this is a stupid question!

Is it possible to measure/record the execution time of queries? I can use libraries in python but if I want to record execution times when executing the query in the influx terminal then I cannot see a way to do this? I feel this should be logged somewhere but I cannot see any evidence of logging either although I know there should be and it appears enabled in the config file ?

Any help would be hugely appreciated :slight_smile:

Have a great day

Monitor Individual Query Duration
#2

True, the influx CLI does not report any timings. But if you’re on a Unix-y system, you should be able to get an approximate execution time for a query via

$ time influx -execute 'SELECT foo FROM bar WHERE time > now() - 10s'

The last field in the HTTP logs (which are enabled by default) is the duration of the request in microseconds:

[httpd] ::1 - - [13/Mar/2017:08:47:41 -0700] "POST /query?chunked=true&db=_internal&epoch=s&q=SELECT+queryRespBytes+FROM+httpd+WHERE+time+%3E+now%28%29+-+30s HTTP/1.1" 200 151 "-" "InfluxDBShell/unknown" 643b51c5-0804-11e7-8004-000000000000 1244

In this case, 1244 means the request took (approximately) 1.244 milliseconds.

1 Like
Slower query time compared to PostgreSQL
#3

@mark , Thanks for such a quick response! I cannot seem to locate my log files? I am running a windows system. Is there a default location in Windows / Can I change the path they are written to ?

Thanks again !

#4

If you start influxd in the foreground (i.e. executing influxd from a command prompt), it normally writes logs to standard error.

I don’t have experience running InfluxDB with Windows, so I’m not sure how people are running it as a service or where logs would normally be expected to be sent to. Unfortunately nothing relevant is turning up on any searches I’ve tried. I assume the logs are going to whatever place is standard for how the influxd service is starting.

#5

As @mark said, influxd.exe will send the logs to stdout which can be redirected to a log file:

C:\Program Files\influxdb>influxd.exe -config influxdb.conf > influxdb.log 2>&1

If you are running InfluxDB as a windows service then the windows service manager will be receiving the logs.

#6

You could also use this InfluxDB client that can show timing information after each operation:

influx> \t
timing is now true
influx> select * from foo | wc -l
64637
timing>
query+network: 1.288792048s
displaying : 457.091811ms