<legend id='sEmin'><style id='sEmin'><dir id='sEmin'><q id='sEmin'></q></dir></style></legend>
<tfoot id='sEmin'></tfoot>

    <bdo id='sEmin'></bdo><ul id='sEmin'></ul>

    <small id='sEmin'></small><noframes id='sEmin'>

    1. <i id='sEmin'><tr id='sEmin'><dt id='sEmin'><q id='sEmin'><span id='sEmin'><b id='sEmin'><form id='sEmin'><ins id='sEmin'></ins><ul id='sEmin'></ul><sub id='sEmin'></sub></form><legend id='sEmin'></legend><bdo id='sEmin'><pre id='sEmin'><center id='sEmin'></center></pre></bdo></b><th id='sEmin'></th></span></q></dt></tr></i><div id='sEmin'><tfoot id='sEmin'></tfoot><dl id='sEmin'><fieldset id='sEmin'></fieldset></dl></div>

      有什么方法可以在不导致 MySQL 锁定的情况下进行

      时间:2023-08-17

      • <bdo id='JDXR1'></bdo><ul id='JDXR1'></ul>
        1. <i id='JDXR1'><tr id='JDXR1'><dt id='JDXR1'><q id='JDXR1'><span id='JDXR1'><b id='JDXR1'><form id='JDXR1'><ins id='JDXR1'></ins><ul id='JDXR1'></ul><sub id='JDXR1'></sub></form><legend id='JDXR1'></legend><bdo id='JDXR1'><pre id='JDXR1'><center id='JDXR1'></center></pre></bdo></b><th id='JDXR1'></th></span></q></dt></tr></i><div id='JDXR1'><tfoot id='JDXR1'></tfoot><dl id='JDXR1'><fieldset id='JDXR1'></fieldset></dl></div>

          1. <small id='JDXR1'></small><noframes id='JDXR1'>

                  <tbody id='JDXR1'></tbody>

                <tfoot id='JDXR1'></tfoot>
                <legend id='JDXR1'><style id='JDXR1'><dir id='JDXR1'><q id='JDXR1'></q></dir></style></legend>
              • 本文介绍了有什么方法可以在不导致 MySQL 锁定的情况下进行选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                查询:

                SELECT COUNT(online.account_id) cnt from online;
                

                但是在线表也被一个事件修改,所以我经常可以通过运行show processlist看到锁.

                But online table is also modified by an event, so frequently I can see lock by running show processlist.

                MySQL 中有没有什么语法可以让 select 语句不引起锁?

                Is there any grammar in MySQL that can make select statement not causing locks?

                我忘记在上面提到它在 MySQL 从数据库上.

                And I've forgotten to mention above that it's on a MySQL slave database.

                在我添加到 my.cnf:transaction-isolation = READ-UNCOMMITTED 之后从站会遇到错误:

                After I added into my.cnf:transaction-isolation = READ-UNCOMMITTED the slave will meet with error:

                错误无法进行二进制日志记录.消息:InnoDB 中的事务级别READ-UNCOMMITTED"对于查询时的二进制日志模式STATEMENT"不安全

                Error 'Binary logging not possible. Message: Transaction level 'READ-UNCOMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'' on query

                那么,有没有兼容的方法来做到这一点?

                So, is there a compatible way to do this?

                推荐答案

                找到一篇名为MYSQL WITH NOLOCK"的文章

                Found an article titled "MYSQL WITH NOLOCK"

                https://web.archive.org/web/20100814144042/http://sqldba.org/articles/22-mysql-with-nolock.aspx

                在 MS SQL Server 中,您将执行以下操作:

                in MS SQL Server you would do the following:

                SELECT * FROM TABLE_NAME WITH (nolock)
                

                和 MYSQL 等价的是

                and the MYSQL equivalent is

                SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
                SELECT * FROM TABLE_NAME ;
                SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ ;
                

                编辑

                Michael Mior 提出以下建议(来自评论)

                Michael Mior suggested the following (from the comments)

                SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
                SELECT * FROM TABLE_NAME ;
                COMMIT ;
                

                这篇关于有什么方法可以在不导致 MySQL 锁定的情况下进行选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:无法通过 socket '/var/lib/mysql/mysql.sock' 连接到 下一篇:MySQL 'Order By' - 正确排序字母数字

                相关文章

                最新文章

                <small id='qhF7Y'></small><noframes id='qhF7Y'>

                  • <bdo id='qhF7Y'></bdo><ul id='qhF7Y'></ul>
                1. <tfoot id='qhF7Y'></tfoot>

                    <i id='qhF7Y'><tr id='qhF7Y'><dt id='qhF7Y'><q id='qhF7Y'><span id='qhF7Y'><b id='qhF7Y'><form id='qhF7Y'><ins id='qhF7Y'></ins><ul id='qhF7Y'></ul><sub id='qhF7Y'></sub></form><legend id='qhF7Y'></legend><bdo id='qhF7Y'><pre id='qhF7Y'><center id='qhF7Y'></center></pre></bdo></b><th id='qhF7Y'></th></span></q></dt></tr></i><div id='qhF7Y'><tfoot id='qhF7Y'></tfoot><dl id='qhF7Y'><fieldset id='qhF7Y'></fieldset></dl></div>

                    <legend id='qhF7Y'><style id='qhF7Y'><dir id='qhF7Y'><q id='qhF7Y'></q></dir></style></legend>