久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <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="qwawimqqmiuu" 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="qwawimqqmiuu" 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 函數(shù),聲稱這比循環(huán)遍歷 3 個單獨的查詢要好.我試圖在谷歌上搜索一些答案,但沒有真正得到任何真正滿足我好奇心的東西,所以我希望你們能更好地了解使用它的原因,而不是節(jié)省幾行代碼.

                  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 是否只是簡單地訪問服務(wù)器 x 次并聚合結(jié)果?
                  3. 是否存在單個查詢可能比多個查詢更有效的情況?

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

                  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 到底在做什么? - 只需將所有查詢一次發(fā)送到服務(wù)器,而不是一次發(fā)送一個,并一次性檢索所有結(jié)果.沒有比這更復(fù)雜的了.

                    • 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 是否只是簡單地點擊服務(wù)器 x 次并聚合結(jié)果? - 它點擊"服務(wù)器兩次 - 一次發(fā)送查詢,一次檢索結(jié)果.

                      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() 在網(wǎng)絡(luò)上很輕,但內(nèi)存很重,在循環(huán)中運行 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.

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

                      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.

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

                      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.

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

                      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.

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

                      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.

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

                      【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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 準備好的語句問題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結(jié)果)
                  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="qwawimqqmiuu" 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>
                            主站蜘蛛池模板: 亚洲精品一区中文字幕 | 久久精品国产一区 | 91精品国产乱码久久久 | 日本午夜在线视频 | 91不卡| 精品麻豆剧传媒av国产九九九 | 久久躁日日躁aaaaxxxx | 久久久精品视频一区二区三区 | 久久精品免费一区二区三 | 欧美性受xxxx白人性爽 | 欧美一级欧美三级在线观看 | 欧美激情视频一区二区三区在线播放 | 国产超碰人人爽人人做人人爱 | 国内精品视频在线观看 | 男人的天堂久久 | 国产成人啪免费观看软件 | 久久综合久久久 | 日韩欧美国产精品 | 国产精品区二区三区日本 | 精品一区二区三区入口 | 国产精品美女久久久久久久久久久 | 99热视| 男女羞羞视频在线 | 美女黄视频网站 | 成人亚洲视频 | 高清成人免费视频 | 成人久久18免费网站图片 | 精品福利一区二区三区 | 欧美综合一区 | 久久一| 国产精品不卡一区 | 99免费 | 免费观看一级毛片视频 | 成人午夜激情 | 国产av毛片 | 日韩免费一区二区 | 久久亚洲国产精品日日av夜夜 | 一a一片一级一片啪啪 | 91久久国产综合久久 | 超碰人人爱| 国产日韩欧美一区二区 |