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

    • <bdo id='TGCys'></bdo><ul id='TGCys'></ul>

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

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

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

    <tfoot id='TGCys'></tfoot>

        mysqli::multi_query 是否比多個單個查詢更有效?

        Is mysqli::multi_query more efficient than several single queries?(mysqli::multi_query 是否比多個單個查詢更有效?)

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

          • <tfoot id='hDS8y'></tfoot>
            <legend id='hDS8y'><style id='hDS8y'><dir id='hDS8y'><q id='hDS8y'></q></dir></style></legend>
            <i id='hDS8y'><tr id='hDS8y'><dt id='hDS8y'><q id='hDS8y'><span id='hDS8y'><b id='hDS8y'><form id='hDS8y'><ins id='hDS8y'></ins><ul id='hDS8y'></ul><sub id='hDS8y'></sub></form><legend id='hDS8y'></legend><bdo id='hDS8y'><pre id='hDS8y'><center id='hDS8y'></center></pre></bdo></b><th id='hDS8y'></th></span></q></dt></tr></i><div class="tzgbd7n" id='hDS8y'><tfoot id='hDS8y'></tfoot><dl id='hDS8y'><fieldset id='hDS8y'></fieldset></dl></div>
          • <small id='hDS8y'></small><noframes id='hDS8y'>

              <tbody id='hDS8y'></tbody>

                1. 本文介紹了mysqli::multi_query 是否比多個單個查詢更有效?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  有人在回答中提到了 MySQLi multi_query 函數,聲稱這比循環遍歷 3 個單獨的查詢要好.我試圖在谷歌上搜索一些答案,但沒有真正得到任何真正滿足我好奇心的東西,所以我希望你們能更好地了解使用它的原因,而不是節省幾行代碼.

                  Someone brought up the MySQLi multi_query function in an answer claiming that it would be better than looping through 3 separate queries. I tried to Google some sort of answer to this but didn't really get anything that really satisfied my curiosity so I hope you guys may have better insights into the reasons for using it rather than saving a few lines of code.

                  所以這就是我想知道的:

                  So here's what I am wondering:

                  1. multi_query 在底層做了什么?
                  2. multi_query 是否只是簡單地訪問服務器 x 次并聚合結果?
                  3. 是否存在單個查詢可能比多個查詢更有效的情況?

                  我知道為每個 100 萬個項目訪問數據庫 3 次并將其粉碎成一個巨大的對象不利于內存使用,但我知道它的存在必須有一個原因,我也確信有是應該避免的時候.我希望能更好地理解它,以便在需要時將其放入我的技巧包中.

                  I know that hitting the database 3 times for a million items each and smashing it into one huge object isn't good for memory usage, but I know that there has to be a reason for its existence and I am also sure there are times when it should be avoided. I hope to better understand it so that I can put that into my bag of tricks when the need arises.

                  感謝您的時間!

                  推薦答案

                  • multi_query 到底在做什么? - 只需將所有查詢一次發送到服務器,而不是一次發送一個,并一次性檢索所有結果.沒有比這更復雜的了.

                    • What is multi_query doing under the hood? - Just sending all the queries to the server at once instead of one at a time, and retrieving all the results in one go. Nothing more complicated than that.

                      multi_query 是否只是簡單地點擊服務器 x 次并聚合結果? - 它點擊"服務器兩次 - 一次發送查詢,一次檢索結果.

                      Does multi_query simply hit the server x number of times and aggregates the results? - It "hits" the server twice - once to send the queries and once to retrieve the results.

                      是否存在單個查詢可能比多個查詢更有效的情況? - 取決于您如何定義高效".multi_query() 在網絡上很輕,但內存很重,在循環中運行 query() 反之亦然.

                      Is there a case where single queries may be more efficient than multiple queries? - depends how you define "efficient". multi_query() is light on the network but memory heavy, running query() in a loop vice versa.

                      對于許多返回大型結果集的 SELECT 語句,內存消耗的損失可能大大超過網絡方面的收益,并且大多數時候您最好發出查詢并一次處理一個結果集 - 盡管這完全取決于您對數據的處理方式.但是如果你需要運行很多 UPDATE 語句,很可能 multi_query() 會更好,因為返回值只是成功/失敗并且內存消耗會很輕.

                      For many SELECT statements that return large result sets the loss in memory consumption is likely to vastly outweigh the gain in terms of the network and most of the time you'd be better to issue the queries and process the result sets one at a time - although this depends on exactly what you are doing with the data. But if you needed to run many UPDATE statements, it is likely that multi_query() would be better since the return values are just success/fail and the memory consumption will be light.

                      您必須權衡所有因素,例如您在做什么、預計需要多長時間、(數據庫)服務器和客戶端之間的網絡延遲、服務器上的可用資源(主要是內存)和客戶等,等等......并根據具體情況進行處理.

                      You would have to weigh up all the factors like what you are doing, how long you expect it to take, the network latency between the (database) server and client, the available resources (mostly memory) on the server and the client, etc, etc... and take it on a case by case basis.

                      我發現這個一些性能測試的記錄做了一個不久前,結論是使用 multi_query() 可以提高整體效率.然而測試用例只是運行 4 個查詢,每個查詢SELECT一個結果,更高效"的定義就是更快".沒有針對大量查詢或更大結果集的測試,雖然速度很重要,但它并不是最重要的 - 如果我給它無限量的內存,我可以使任何東西運行得非??欤菄L試同時做任何事情都會失敗.這也不是真實世界的測試,因為最終結果可以通過單個 JOIN ed 查詢來實現.不過,它確實會帶來一些有趣的閱讀.

                      I found this record of some performance testing done a while ago, where the conclusion is that there is an overall efficiency gain to be found from using multi_query(). However the test case was simply running 4 queries, each one SELECTing a single result, and the definition of "more efficient" is simply "faster". There is no testing for larger numbers of queries or larger result sets and, while speed is important, it is not the be-all and end-all - I can make anything run incredibly fast if I give it an unlimited amount of memory, but an attempt to do anything concurrently will fail miserably. It is also not a real world test, since the end result could be achieved with a single JOINed query. It does make for some interesting read though.

                      我個人覺得這有點學術性,因為如果您一次運行大量語句,則 90% 的時間它們只會在傳遞的數據和查詢結構方面有所不同將保持不變 - 這是準備好的語句的明顯候選.

                      Personally I feel this is somewhat academic because if you are running a large set of statements at once, 90% of the time they will vary only in the data that is being passed and the query structure will remain the same - which is an obvious candidate for prepared statements.

                      這篇關于mysqli::multi_query 是否比多個單個查詢更有效?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                      【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                  Call to undefined function mysqli_result::num_rows()(調用未定義的函數 mysqli_result::num_rows())
                  PHP Prepared Statement Problems(PHP 準備好的語句問題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結果)
                  PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                  How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)
                  • <i id='gu2vt'><tr id='gu2vt'><dt id='gu2vt'><q id='gu2vt'><span id='gu2vt'><b id='gu2vt'><form id='gu2vt'><ins id='gu2vt'></ins><ul id='gu2vt'></ul><sub id='gu2vt'></sub></form><legend id='gu2vt'></legend><bdo id='gu2vt'><pre id='gu2vt'><center id='gu2vt'></center></pre></bdo></b><th id='gu2vt'></th></span></q></dt></tr></i><div class="itdfl8w" id='gu2vt'><tfoot id='gu2vt'></tfoot><dl id='gu2vt'><fieldset id='gu2vt'></fieldset></dl></div>

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

                        <tfoot id='gu2vt'></tfoot>
                        • <legend id='gu2vt'><style id='gu2vt'><dir id='gu2vt'><q id='gu2vt'></q></dir></style></legend>
                            <tbody id='gu2vt'></tbody>
                            <bdo id='gu2vt'></bdo><ul id='gu2vt'></ul>
                            主站蜘蛛池模板: 缝纫客 | 伟秀电气有限公司-10kv高低压开关柜-高低压配电柜-中置柜-充气柜-欧式箱变-高压真空断路器厂家 | 美缝剂_美缝剂厂家_美缝剂加盟-地老板高端瓷砖美缝剂 | 色谱柱-淋洗液罐-巴罗克试剂槽-巴氏吸管-5ml样品瓶-SBS液氮冻存管-上海希言科学仪器有限公司 | 艾默生变频器,艾默生ct,变频器,ct驱动器,广州艾默生变频器,供水专用变频器,风机变频器,电梯变频器,艾默生变频器代理-广州市盟雄贸易有限公司官方网站-艾默生变频器应用解决方案服务商 | 探鸣起名网-品牌起名-英文商标起名-公司命名-企业取名包满意 | 北京燃气公司 用户服务中心 | 开锐教育-学历提升-职称评定-职业资格培训-积分入户 | 小学教案模板_中学教师优秀教案_高中教学设计模板_教育巴巴 | 高精度电阻回路测试仪-回路直流电阻测试仪-武汉特高压电力科技有限公司 | 登车桥动力单元-非标液压泵站-非标液压系统-深圳市三好科技有限公司 | 护栏打桩机-打桩机厂家-恒新重工| 深圳彩钢板_彩钢瓦_岩棉板_夹芯板_防火复合彩钢板_长鑫 | 伟秀电气有限公司-10kv高低压开关柜-高低压配电柜-中置柜-充气柜-欧式箱变-高压真空断路器厂家 | 不锈钢螺丝,不锈钢螺栓,不锈钢标准件-江苏百德特种合金有限公司 交变/复合盐雾试验箱-高低温冲击试验箱_安奈设备产品供应杭州/江苏南京/安徽马鞍山合肥等全国各地 | 旗杆生产厂家_不锈钢锥形旗杆价格_铝合金电动旗杆-上海锥升金属科技有限公司 | 精密线材测试仪-电线电缆检测仪-苏州欣硕电子科技有限公司 | 低温等离子清洗机(双气路进口)-嘉润万丰 | 电加热导热油炉-空气加热器-导热油加热器-翅片电加热管-科安达机械 | 橡胶接头|可曲挠橡胶接头|橡胶软接头安装使用教程-上海松夏官方网站 | 自动售货机_无人售货机_专业的自动售货机运营商_免费投放售货机-广州富宏主官网 | 空气净化器租赁,空气净化器出租,全国直租_奥司汀净化器租赁 | 成都顶呱呱信息技术有限公司-贷款_个人贷款_银行贷款在线申请 - 成都贷款公司 | 重庆中专|职高|技校招生-重庆中专招生网 | 办公室家具_板式办公家具定制厂家-FMARTS福玛仕办公家具 | 权威废金属|废塑料|废纸|废铜|废钢价格|再生资源回收行情报价中心-中废网 | 知企服务-企业综合服务(ZiKeys.com)-品优低价、种类齐全、过程管理透明、速度快捷高效、放心服务,知企专家! | 恒湿机_除湿加湿一体机_恒湿净化消毒一体机厂家-杭州英腾电器有限公司 | 济南画室培训-美术高考培训-山东艺霖艺术培训画室 | 数控专用机床,专用机床,自动线,组合机床,动力头,自动化加工生产线,江苏海鑫机床有限公司 | 江苏全风,高压风机,全风环保风机,全风环形高压风机,防爆高压风机厂家-江苏全风环保科技有限公司(官网) | 懂研帝_专业SCI论文润色机构_SCI投稿发表服务公司 | 抓斗式清污机|螺杆式|卷扬式启闭机|底轴驱动钢坝|污水处理闸门-方源水利机械 | 变频器维修公司_plc维修_伺服驱动器维修_工控机维修 - 夫唯科技 变位机,焊接变位机,焊接变位器,小型变位机,小型焊接变位机-济南上弘机电设备有限公司 | 气力输送_输送机械_自动化配料系统_负压吸送_制造主力军江苏高达智能装备有限公司! | 扬子叉车厂家_升降平台_电动搬运车|堆高车-扬子仓储叉车官网 | 智慧农业|农业物联网|现代农业物联网-托普云农物联网官方网站 | 电动卫生级调节阀,电动防爆球阀,电动软密封蝶阀,气动高压球阀,气动对夹蝶阀,气动V型调节球阀-上海川沪阀门有限公司 | 船用锚链|专业锚链生产厂家|安徽亚太锚链制造有限公司 | 抓斗式清污机|螺杆式|卷扬式启闭机|底轴驱动钢坝|污水处理闸门-方源水利机械 | 视频直播 -摄影摄像-视频拍摄-直播分发|