什么时候在MySQL(MyISAM表)中锁定表? [英] When to LOCK TABLES in MySQL (MyISAM tables)?

查看:475
本文介绍了什么时候在MySQL(MyISAM表)中锁定表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MySQL内部锁定足以满足一个中小型网站?我的表是MyISAM。可能有几百人同时使用SELECT'S和INSERT命中一个特定的表。 INSERT / UPDATE查询都不会重叠。也就是说,没有两个用户将更新相同的注释ID。 INSERT / UPDATE是一次性的操作---不会在同一个查询中读取数据和执行额外的操作。

Is the internal locking of MySQL sufficient for a small to medium sized website? My tables are MyISAM. There might be a few hundred people concurrently hitting a specific table with SELECT'S and INSERT's. None of the INSERT/UPDATE queries would overlap. That is, no two users will be updating the same comment ID. INSERT's/UPDATE's would be one-off operations---there would be no reading of data and performing additional operations within the same query.

具体来说,我设置了一个我的网站的评论/聊天系统。在最坏的情况下,可能有几百个人在评论/聊天表上执行SELECT语句以读取新帖子。对于INSERT,可能有100(?)个不同的人试图随时插入新的评论。

Specifically, I am setting up a comment/chat system for my website. At worst, there might be a couple of hundred people performing a SELECT statement on the comment/chat tables in order to read new posts. With respect to INSERT's, there might be 100(?) different people trying to INSERT a new comment at any time.

我发现这篇文章在另一个问题上的SO,并指出,LOCK TABLES是从不需要自包含插入,更新或删除操作。这是我可能有多少数据库流量的良好做法?

I found this article in another question on SO, and it states that LOCK TABLES is "never required for self-contained insert, update, or delete operations." Is this good practice for the amount of DB traffic that I might have? TIA for any advice.

推荐答案

锁定MyISAM表的唯一形式是表锁。这个想法是他们设计的方式足够快,没有其他人在工作时需要访问。右 - YMM绝对五。但对于大多数中小型网站,这是很好。对于intance,这就是WordPress使用的。

The only form of locking MyISAM tables is table locks. The idea is that they designed it to be way-fast enough that no one else should need access while it works. Right - YMM definitely V. But for most small-to-medium-size websites, it's fine. For intance, that's what WordPress uses.

这篇关于什么时候在MySQL(MyISAM表)中锁定表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆