二进制文件里面的exec_time是什么意思

原文:http://www.mysqlperformanceblog.com/2011/01/31/what-is-exec_time-in-binary-logs/

If you’ve used MySQL’s mysqlbinlog tool, you’ve probably seen something like the following in the output: “exec_time=0″ What is the exec_time? It seems to be the query’s execution time, but it is not.

In most cases, the exec_time will be similar to the query execution time on the server where the query originally ran. If you’re running replication, then on the replication master, the exec_time will look believable. But on replicas, exec_time can be completely different. Suppose you execute an UPDATE that takes one second to run on the master. This gets logged into the binary log and copied to replicas for replay. Now suppose that you have also set log_slave_updates on the replica. When the statement executes in the replication thread, it will be logged to the replica’s binary log so it can be replicated to other servers in turn.

If you use mysqlbinlog to examine the replica’s binary log, you might see a very different exec_time, such as exec_time=1000, even if the statement did not take 1000 seconds to execute. Why is that?

The reason is that the exec_time is the difference from the statement’s original start timestamp and the time at which it completed executing. On the originating server, that’s accurate to within the tolerance of a one-second timestamp. However, replicas might execute the statement much later. And in those cases, the end timestamp will be much later than the start timestamp on the originating server, thus causing the statement to appear to have taken a long time to execute.


当你是使用MySQL的二进制文件查看工具查看二进制文件的时候,可能会发现里面有一部分输出的内容是:"exec_time=0",那exec_time是什么意思?这个看起来是语句的执行时间,但这可能并不一定。

在大多情况下,exec_time会和语句真实的执行时间比较接近,但当你在主从环境下执行这个的时候就可能会发生不一定的情况。

但你在从上面设置了log_slave_update=1以后,主上面过来的操作会同样写到从的二进制文件里,那你就会发现,可能在主上面的exec_time=0的情况到从的二进制文件里面就变成了exec_time=1000,这个主要是因为时间的计算是根据主二进制文件里面的语句时间戳进行的计算,那当这个语句在从上面执行以后,时间可能已经过了很久,因此在从上面的exec_time的值计算方式就是:主执行语句的起始时间到从执行完这个语句的结束时间,因此这个exec_time会变得和主差别较大,这个时候我认为是不用担心的,主要根据主上面的exec_time去判断语句的执行时长的就可了。

看了一下博客的评论,里面有一个观点,用这个数也可以大概判断一下语句的执行延迟时长。但这个计算方式已经有MySQL的状态显示出来了,现在看来,当初MySQL开发延迟的时候,会不会是考虑了这种计算方式呢?呵呵。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import subprocess import cv2 import numpy as np import time import calendar #从手机获取二进制图片 def get_app_img(): # 从ADB获取屏幕图像 try: output = subprocess.check_output('adb exec-out screencap -p', shell=True) # 处理 output 中的数据 except subprocess.CalledProcessError as e: print('Error:', e) except Exception as e: print('Unexpected error:', e) return output #获取每一张图片的三维数据 def get_imgdecdoe(): output = get_app_img() # print("------output-----{}".format(output)) # 将输出转换为图像 image1 = cv2.imdecode(np.fromstring(output, dtype='uint8'), cv2.IMREAD_COLOR) # print(image) # #缩小图片的大小 image = cv2.resize(image1, (int(1080 / 3), int(2340 / 3))) return image def app_video(): save_path=r"E:\myTool\appium_xiangmu\test_video" ts=calendar.timegm(time.gmtime()) videoname = str(ts)+ ".mp4" save_file_path = '{}\\{}'.format(save_path, videoname) #保存视频 fourcc = cv2.VideoWriter_fourcc(*'mp4v') # 不同视频编码对应不同视频格式(例:'I','4','2','0' 对应avi格式) video = cv2.VideoWriter(save_file_path, fourcc, 5, (int(1080/3),int(2340/3))) try: while True: image = get_imgdecdoe() # 显示图像 cv2.imshow('Screen', image) # 按下ESC键退出循环 if cv2.waitKey(1) == 27: break image=get_imgdecdoe() video.write(image) finally: video.release() #释放 print("________视频处理完毕_______:视频号显示:{}".format(videoname)) cv2.destroyAllWindows() if __name__ == '__main__': app_video(),缺少录制时用户的点击的提示怎么处理,有实例代码吗
最新发布
06-08

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值