pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

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

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

      <legend id='Ptlx7'><style id='Ptlx7'><dir id='Ptlx7'><q id='Ptlx7'></q></dir></style></legend>
    1. 刷新 mysqli_multi_query() 的速度/最佳實(shí)踐

      Speed/best practice flushing mysqli_multi_query()(刷新 mysqli_multi_query() 的速度/最佳實(shí)踐)
          <tbody id='Yj2qv'></tbody>

        • <bdo id='Yj2qv'></bdo><ul id='Yj2qv'></ul>
        • <small id='Yj2qv'></small><noframes id='Yj2qv'>

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

              <tfoot id='Yj2qv'></tfoot>
            1. <legend id='Yj2qv'><style id='Yj2qv'><dir id='Yj2qv'><q id='Yj2qv'></q></dir></style></legend>

              1. 本文介紹了刷新 mysqli_multi_query() 的速度/最佳實(shí)踐的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                當(dāng)塞巴斯蒂安說(shuō)他要斷開(kāi)連接時(shí),我感到很害怕&在每次使用 mysqli_multi_query() 之間重新連接@可以 mysqli_multi_query執(zhí)行 UPDATE 語(yǔ)句? 因?yàn)檫@似乎不是最佳實(shí)踐.

                I cringed when Sebastien stated he was disconnecting & reconnecting between each use of mysqli_multi_query() @ Can mysqli_multi_query do UPDATE statements? because it just didn't seem like best practice.

                但是,Craig @ mysqli multi_query 后跟查詢(xún) 在他的案例中說(shuō)明斷開(kāi)連接速度更快在每次使用 mysqli_multi_query() 之間重新連接而不是使用 mysqli_next_result().

                However, Craig @ mysqli multi_query followed by query stated in his case that it was faster to disconnect & reconnect between each use of mysqli_multi_query() than to employ mysqli_next_result().

                我想問(wèn)一下,當(dāng)程序員應(yīng)該選擇新連接"還是下一個(gè)結(jié)果"方法時(shí),是否有人有進(jìn)一步的第一手知識(shí)或基準(zhǔn)證據(jù)來(lái)建議一個(gè)近似的截止"(基于查詢(xún)量或其他東西).

                I would like to ask if anyone has further first-hand knowledge or benchmark evidence to suggest an approximate "cutoff" (based on query volume or something) when a programmer should choose the "new connection" versus "next result" method.

                我也很高興聽(tīng)到任何/所有與速度無(wú)關(guān)的問(wèn)題.Craig 使用連接函數(shù)對(duì)速度有影響嗎?

                I am also happy to hear any/all concerns not pertaining to speed. Does Craig's use of a connecting function have any bearing on speed?

                Craig 的 while 語(yǔ)句之間是否存在速度差異:

                Is there a speed difference between Craig's while statement:

                while ($mysqli->next_result()) {;}
                

                - 對(duì) -

                我建議的 while 語(yǔ)句:

                a while statement that I'm suggesting:

                while(mysqli_more_results($mysqli) && mysqli_next_result($mysqli));
                

                - 對(duì) -

                在運(yùn)行第一個(gè) multi_query 之前,為每個(gè)預(yù)期的 multi_query 創(chuàng)建一個(gè)新連接.我剛剛測(cè)試了這個(gè),兩個(gè) mysqli_multi_query() 沒(méi)有錯(cuò)誤 = 不需要 close():

                creating a new connection for each expected multi_query, before running first multi_query. I just tested this, and the two mysqli_multi_query()s were error free = no close() needed:

                $mysqli1=mysqli_connect("$host","$user","$pass","$db");
                $mysqli2=mysqli_connect("$host","$user","$pass","$db");
                

                - 對(duì) -

                在每個(gè) mysqli_multi_query() 之間打開(kāi)和關(guān)閉,如 Sebastien 和 Craig:

                Opening and closing between each mysqli_multi_query() like Sebastien and Craig:

                $mysqli = newSQL();
                $mysqli->multi_query($multiUpdates);
                $mysqli->close();
                

                - 對(duì) -

                有人有其他選擇來(lái)測(cè)試嗎?

                Anyone have another option to test against?

                推薦答案

                責(zé)怪不是 next_result() 而是查詢(xún)自己.代碼運(yùn)行所需的時(shí)間取決于執(zhí)行實(shí)際查詢(xún)所需的時(shí)間.

                It is not next_result() to blame but queries themselves. The time your code takes to run relies on the time actual queries take to perform.

                雖然 mysqli_multi_query() 返回控制的速度相當(dāng)快,這并不意味著所有查詢(xún)都在那個(gè)時(shí)候執(zhí)行了. 恰恰相反,到時(shí)候 mysqli_multi_query() 完成,只執(zhí)行了第一個(gè)查詢(xún). 而所有其他查詢(xún)都在 mysql 端排隊(duì)等待異步執(zhí)行.

                Although mysqli_multi_query() returns control quite fast, it doesn't mean that all queries got executed by that time. Quite contrary, by the time mysqli_multi_query() finished, only first query got executed. While all other queries are queued on the mysql side for the asynchronous execution.

                由此您可以得出結(jié)論,next_result() 調(diào)用本身不會(huì)添加任何超時(shí) - 它只是在等待下一個(gè)查詢(xún)完成.如果查詢(xún)本身需要時(shí)間,那么 next_result() 也必須等待.

                From this you may conclude that next_result() call doesn't add any timeout by itself - it's just waiting for the next query to finish. And if query itself takes time, then next_result() have to wait as well.

                知道您可能已經(jīng)知道選擇哪種方式:如果您不關(guān)心結(jié)果,您可能只是關(guān)閉連接.但事實(shí)上,它只會(huì)掃除地毯下的污垢,將所有緩慢的查詢(xún)留在原處.因此,最好保持 next_result() 循環(huán)到位(尤其是因?yàn)槟仨殭z查錯(cuò)誤/受影響的行/等)但加快查詢(xún)本身.

                Knowing that you already may tell which way to choose: if you don't care for the results, you may just close the connection. But in fact, it'll be just sweeping dirt under the rug, leaving all the slow queries in place. So, it's better to keep next_result() loop in place (especially because you have to check for errors/affected rows/etc. anyway) but speed up the queries themselves.

                所以,事實(shí)證明,要解決next_result() 的問(wèn)題,您必須實(shí)際解決查詢(xún)速度的常規(guī)問(wèn)題.所以,這里有一些建議:

                So, it turns out that to solve the problem with next_result() you have to actually solve the regular problem of the query speed. So, here are some recommendations:

                1. 對(duì)于選擇查詢(xún),它通常是索引/解釋分析,已經(jīng)在其他答案中解釋過(guò).
                2. 對(duì)于 DML 查詢(xún),尤其是批量運(yùn)行,還有其他方式:

                說(shuō)到 Craig 的案例,它與已知的 innodb 寫(xiě)入速度問(wèn)題非常相似.默認(rèn)情況下,innodb 引擎設(shè)置為非常謹(jǐn)慎的模式,在引擎確保前一次成功完成之前,不會(huì)執(zhí)行后續(xù)寫(xiě)入.因此,它使寫(xiě)入非常緩慢(大約只有 10 個(gè)查詢(xún)/秒).對(duì)此的常見(jiàn)解決方法是一次進(jìn)行所有寫(xiě)入.對(duì)于插入查詢(xún),有很多方法:

                Speaking of Craig's case, it's quite much resembling the known problem of speed of innodb writes. By default, innodb engine is set up into very cautious mode, where no following write is performed until engine ensured that previous one were finished successfully. So, it makes writes awfully slow (something like only 10 queries/sec). The common workaround for this is to make all the writes at once. For insert queries there are plenty of methods:

                • 您可以使用多個(gè)值插入語(yǔ)法
                • 您可以使用 LOAD DATA INFILE 查詢(xún)
                • 您可以將所有查詢(xún)包裝在一個(gè)事務(wù)中.

                雖然僅更新和刪除事務(wù)仍然是可靠的方式.因此,作為通用解決方案,可以提供這樣的解決方法

                While for updating and deleting only transaction remains reliable way. So, as a universal solution such a workaround can be offered

                 $multiSQL = "BEGIN;{$multiSQL}COMMIT;";
                 $mysqli->multi_query($multiSQL);
                 while ($mysqli->next_result()) {/* check results here *
                                
                【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                Call to undefined function mysqli_result::num_rows()(調(diào)用未定義的函數(shù) mysqli_result::num_rows())
                PHP Prepared Statement Problems(PHP 準(zhǔn)備好的語(yǔ)句問(wèn)題)
                mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個(gè)結(jié)果)
                PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類(lèi)型?)

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

                          <tbody id='qktUm'></tbody>
                      1. <small id='qktUm'></small><noframes id='qktUm'>

                        • <legend id='qktUm'><style id='qktUm'><dir id='qktUm'><q id='qktUm'></q></dir></style></legend>
                          <tfoot id='qktUm'></tfoot>
                          主站蜘蛛池模板: 股票入门基础知识_股票知识_股票投资大师_格雷厄姆网 | 混合生育酚_醋酸生育酚粉_琥珀酸生育酚-山东新元素生物科技 | 桥架-槽式电缆桥架-镀锌桥架-托盘式桥架 - 上海亮族电缆桥架制造有限公司 | 强效碱性清洗剂-实验室中性清洗剂-食品级高纯氮气发生器-上海润榕科学器材有限公司 | 交变/复合盐雾试验箱-高低温冲击试验箱_安奈设备产品供应杭州/江苏南京/安徽马鞍山合肥等全国各地 | 防水套管|柔性防水套管|伸缩器|伸缩接头|传力接头-河南伟创管道 防水套管_柔性防水套管_刚性防水套管-巩义市润达管道设备制造有限公司 | 杭州实验室尾气处理_实验台_实验室家具_杭州秋叶实验设备有限公司 | 油液红外光谱仪-油液监测系统-燃油嗅探仪-上海冉超光电科技有限公司 | 广东泵阀展|阀门展-广东国际泵管阀展览会 | 多米诺-多米诺世界纪录团队-多米诺世界-多米诺团队培训-多米诺公关活动-多米诺创意广告-多米诺大型表演-多米诺专业赛事 | 考试试题_试卷及答案_诗词单词成语 - 优易学| 北京租车牌|京牌指标租赁|小客车指标出租 | 脉冲布袋除尘器_除尘布袋-泊头市净化除尘设备生产厂家 | 活性炭-果壳木质煤质柱状粉状蜂窝活性炭厂家价格多少钱 | 2025世界机器人大会_IC China_半导体展_集成电路博览会_智能制造展览网 | 定制异形重型钢格栅板/钢格板_定做踏步板/排水沟盖板_钢格栅板批发厂家-河北圣墨金属制品有限公司 | 流变仪-热分析联用仪-热膨胀仪厂家-耐驰科学仪器商贸 | 福建自考_福建自学考试网 | 高温热泵烘干机,高温烘干热泵,热水设备机组_正旭热泵 | 连续密炼机_双转子连续密炼机_连续式密炼机-南京永睿机械制造有限公司 | 舞台木地板厂家_体育运动木地板_室内篮球馆木地板_实木运动地板厂家_欧氏篮球地板推荐 | 碳化硅,氮化硅,冰晶石,绢云母,氟化铝,白刚玉,棕刚玉,石墨,铝粉,铁粉,金属硅粉,金属铝粉,氧化铝粉,硅微粉,蓝晶石,红柱石,莫来石,粉煤灰,三聚磷酸钠,六偏磷酸钠,硫酸镁-皓泉新材料 | 超细|超微气流粉碎机|气流磨|气流分级机|粉体改性机|磨粉机|粉碎设备-山东埃尔派粉体科技 | 锂电池生产厂家-电动自行车航模无人机锂电池定制-世豹新能源 | vr安全体验馆|交通安全|工地安全|禁毒|消防|安全教育体验馆|安全体验教室-贝森德(深圳)科技 | 破碎机锤头_耐磨锤头_合金锤头-鼎成机械一站式耐磨铸件定制服务 微型驱动系统解决方案-深圳市兆威机电股份有限公司 | 北京工业设计公司-产品外观设计-产品设计公司-千策良品工业设计 北京翻译公司-专业合同翻译-医学标书翻译收费标准-慕迪灵 | PU树脂_水性聚氨酯树脂_聚氨酯固化剂_聚氨酯树脂厂家_宝景化工 | 电力测功机,电涡流测功机,磁粉制动器,南通远辰曳引机测试台 | 浙江富广阀门有限公司| 北京征地律师,征地拆迁律师,专业拆迁律师,北京拆迁律师,征地纠纷律师,征地诉讼律师,征地拆迁补偿,拆迁律师 - 北京凯诺律师事务所 | 原色会计-合肥注册公司_合肥代理记账公司_营业执照代办 | 密集架-手摇-智能-移动-价格_内蒙古档案密集架生产厂家 | 回转炉,外热式回转窑,回转窑炉-淄博圣元窑炉工程有限公司 | 石英陶瓷,石英坩埚,二氧化硅陶瓷-淄博百特高新材料有限公司 | 洗砂机械-球磨制砂机-洗沙制砂机械设备_青州冠诚重工机械有限公司 | 胶原检测试剂盒,弹性蛋白检测试剂盒,类克ELISA试剂盒,阿达木单抗ELISA试剂盒-北京群晓科苑生物技术有限公司 | app开发|app开发公司|小程序开发|物联网开发||北京网站制作|--前潮网络 | atcc网站,sigma试剂价格,肿瘤细胞现货,人结肠癌细胞株购买-南京科佰生物 | 背压阀|减压器|不锈钢减压器|减压阀|卫生级背压阀|单向阀|背压阀厂家-上海沃原自控阀门有限公司 本安接线盒-本安电路用接线盒-本安分线盒-矿用电话接线盒-JHH生产厂家-宁波龙亿电子科技有限公司 | ptc_浴霸_大巴_干衣机_呼吸机_毛巾架_电动车加热器-上海帕克 |