Query execution time measurement

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kneighbour
Posts: 77
Joined: Wed 08 Oct 2008 04:55

Query execution time measurement

Post by kneighbour » Thu 25 Jul 2019 00:37

I am using Delphi XE7 and IBDAC 7 and UniDac 8. I have recently started using the SQLMonitor function to try and analyse query performance and it has been a great help. It is working as far as it goes, but I would really like to get specific information on how long each query takes.

Currently I log the output of SQLMonitor to a text/log file, and I record the time of the entry in the log file. I can also work out the time between the last log entry and the current one, and record that as well. But that is not the same thing as working out the actual query time.

I had thought to do this at the UniQuery level. ie record an entry in the BeforeOpen and then AfterOpen events. While this would seem to work, it is not a global function it is not really that practical.

UniConnection has DefaultTransaction events (OnStart and OnCommit). You don't seem to be able to use these events, but in theory, could these be used to time things?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Query execution time measurement

Post by ViktorV » Fri 26 Jul 2019 12:09

These event handlers are not designed to estimate the execution time of a query on the server - in most cases, you'll get unpredictable and inaccurate estimation.
You can use the TUniQuery.BeforeExecute and TUniQuery.AfterExecute event handlers to estimate the execution time of the TUniQuery.Execute method.

Post Reply