在VB.NET中记录MySQL数据库的查询执行时间

时间:2022-10-13 12:07:45

I have an application coded in VB, and i was wondering if there is any way in which I am able to retrieve query execution time for a MySQL query.

我有一个用VB编写的应用程序,我想知道是否有任何方法可以检索MySQL查询的查询执行时间。

I can see it in Workbench but I am looking to consign these into my application for query statistic reporting.

我可以在Workbench中看到它,但我希望将这些内容托付到我的查询统计报告应用程序中。

Does anyone have any material on this, I cannot seem to find what I want other than "Use Workbench for this"?

有没有人对此有任何材料,我似乎找不到除了“Use Workbench for this”之外我想要的东西?

1 个解决方案

#1


0  

You can use a Stopwatch to measure the execution time. Please note that you should start the watch after the connection is opened.

您可以使用秒表来测量执行时间。请注意,您应该在打开连接后启动手表。

con.Open()

Dim watch As New Stopwatch()

watch.Start()
cmd.ExecuteNonQuery()
watch.Stop()

con.Close()

Dim seconds As Double = watch.Elapsed.TotalSeconds()

#1


0  

You can use a Stopwatch to measure the execution time. Please note that you should start the watch after the connection is opened.

您可以使用秒表来测量执行时间。请注意,您应该在打开连接后启动手表。

con.Open()

Dim watch As New Stopwatch()

watch.Start()
cmd.ExecuteNonQuery()
watch.Stop()

con.Close()

Dim seconds As Double = watch.Elapsed.TotalSeconds()