找回密码
 FreeOZ用户注册
查看: 1797|回复: 7
打印 上一主题 下一主题

[学习深造] Which data structure to use?

[复制链接]
跳转到指定楼层
1#
发表于 10-2-2016 08:40:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?FreeOZ用户注册

x
本帖最后由 DDD888 于 10-2-2016 09:42 编辑

Sometimes the webserver I develop faced crashing due to some sql running a long long time i.e. running 30 minutes. Not very often. Once in two years. I don't want to turn on mysql long query log function. I want to develop code to log such sql if running without return from mysql.

I am thinking that I log the sql before sending to the sql server with a datetime stamp. If the sql query finished running on sql server and return to my code, I will deleted the sql record in my bookkeeping. I might face multiple same sql statement submit to the server, I think that I don't care the order to delete the sql as long as they runs very quickly, not the trouble making sql.

What data structure should I use? I think that array might not fit the bill, as I need to do bookkeeping about finding the empty cell to fill in and remove the sql in the cell.

What do you think? Thanks in advance
回复  

使用道具 举报

2#
发表于 10-2-2016 09:27:51 | 只看该作者
你的应用和数据库之间的连接是没time out的吗?log应该是数据库做的。应用可以Log所有超时的sql。
回复  

使用道具 举报

3#
 楼主| 发表于 10-2-2016 09:58:53 | 只看该作者
mason00 发表于 10-2-2016 10:27
你的应用和数据库之间的连接是没time out的吗?log应该是数据库做的。应用可以Log所有超时的sql。

Thanks

I am asking my boss if he want that solution.
回复  

使用道具 举报

4#
 楼主| 发表于 10-2-2016 10:02:22 | 只看该作者
本帖最后由 DDD888 于 10-2-2016 11:39 编辑
DDD888 发表于 10-2-2016 10:58
Thanks

I am asking my boss if he want that solution.


My boss said no. He said that timeout might affect mysql database replication. I asked him to clarify it. And he said only as temporary solution using timeout. I still need to solve my original question.
回复  

使用道具 举报

5#
发表于 10-2-2016 11:59:55 | 只看该作者
DDD888 发表于 10-2-2016 10:02
My boss said no. He said that timeout might affect mysql database replication. I asked him to cl ...

没有time out,你还是可以让sql数据库自己记录Long query。你可以分析数据库log。
回复  

使用道具 举报

6#
发表于 10-2-2016 12:00:54 | 只看该作者
DDD888 发表于 10-2-2016 10:02
My boss said no. He said that timeout might affect mysql database replication. I asked him to cl ...

应用和数据库之间的连接time out,不是数据库全局的所有链接time out。
回复  

使用道具 举报

7#
 楼主| 发表于 10-2-2016 12:23:56 | 只看该作者
mason00 发表于 10-2-2016 12:59
没有time out,你还是可以让sql数据库自己记录Long query。你可以分析数据库log。

My boss turned off mysql database log. The server is very busy and the server generates lots of database log. It is outside of my control. My boss is the database admin.
回复  

使用道具 举报

8#
 楼主| 发表于 10-2-2016 12:24:26 | 只看该作者
mason00 发表于 10-2-2016 13:00
应用和数据库之间的连接time out,不是数据库全局的所有链接time out。

That is what I told him. He agrees.
回复  

使用道具 举报

您需要登录后才可以回帖 登录 | FreeOZ用户注册

本版积分规则

小黑屋|手机版|Archiver|FreeOZ论坛

GMT+10, 25-6-2025 22:55 , Processed in 0.036647 second(s), 23 queries , Gzip On, Redis On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表