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

<tfoot id='23QSg'></tfoot>

      <bdo id='23QSg'></bdo><ul id='23QSg'></ul>

    <small id='23QSg'></small><noframes id='23QSg'>

  1. <legend id='23QSg'><style id='23QSg'><dir id='23QSg'><q id='23QSg'></q></dir></style></legend>
      <i id='23QSg'><tr id='23QSg'><dt id='23QSg'><q id='23QSg'><span id='23QSg'><b id='23QSg'><form id='23QSg'><ins id='23QSg'></ins><ul id='23QSg'></ul><sub id='23QSg'></sub></form><legend id='23QSg'></legend><bdo id='23QSg'><pre id='23QSg'><center id='23QSg'></center></pre></bdo></b><th id='23QSg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='23QSg'><tfoot id='23QSg'></tfoot><dl id='23QSg'><fieldset id='23QSg'></fieldset></dl></div>
    1. 為什么在 PHP 和 MySQL 中使用 PDO 的某些類型的準備

      Why are certain types of prepared queries using PDO in PHP with MySQL slow?(為什么在 PHP 和 MySQL 中使用 PDO 的某些類型的準備查詢很慢?)

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

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

            • <small id='oAHEn'></small><noframes id='oAHEn'>

              <legend id='oAHEn'><style id='oAHEn'><dir id='oAHEn'><q id='oAHEn'></q></dir></style></legend>
                本文介紹了為什么在 PHP 和 MySQL 中使用 PDO 的某些類型的準備查詢很慢?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                當使用 SELECT * FROM table WHERE Id IN ( .. ) 查詢超過 10000 個鍵時,使用 PDO 和 prepare()/execute(),性能下降約 10 倍使用帶有準備好的語句的 mysqli 或不使用準備好的語句的 PDO 進行查詢.

                When using SELECT * FROM table WHERE Id IN ( .. ) queries with more than 10000 keys using PDO with prepare()/execute(), the performance degrades ~10X more than doing the same query using mysqli with prepared statements or PDO without using prepared statements.

                更多奇怪的細節(jié):

                • 更典型的 SELECT 語句沒有 WHERE Id IN( ..) 子句,即使有 100K+ 行也能很好地執(zhí)行.SELECT * FROM table WHERE Id 例如很快.

                • More typical SELECT statements that don't have the WHERE Id IN( ..) clause perform fine even with 100K+ rows. SELECT * FROM table WHERE Id for example is fast.

                性能下降發(fā)生在 prepare()/execute() 完成之后 - 它完全在 PDOStatement::fetch()PDOStatement::fetchAll() 中>.在所有情況下,MySQL 查詢執(zhí)行時間都很短 - 這不是 MySQL 優(yōu)化的情況.

                The performance degradation occurs after prepare()/execute() is complete - it's entirely in PDOStatement::fetch() or PDOStatement::fetchAll(). The MySQL query execution time is tiny in all cases - this isn't a case of a MySQL optimization.

                將 10K 查詢拆分為 10 個具有 1K 鍵的查詢是高效的.

                Splitting the 10K query into 10 queries with 1K keys is performant.

                使用 mysql、帶有準備語句的 mysqli 或不帶準備語句的 PDO 是高性能的.

                Using mysql, mysqli with prepared statements, or PDO without prepared statements is performant.

                PDO w/prepared 在下面的例子中需要約 6 秒,而其他需要約 0.5 秒.

                PDO w/prepared takes ~6 seconds on the example below, while the others take ~0.5s.

                您擁有的密鑰越多,非線性就會變得更糟.嘗試 10 萬個密鑰.

                It gets worse in a non-linear fashion the more keys you have. Try 100K keys.

                示例代碼:

                // $imageIds is an array with 10K keys
                $keyCount = count($imageIds);
                $keys = implode(', ', array_fill(0, $keyCount, '?'));
                $query = "SELECT * FROM images WHERE ImageID IN ({$keys})";
                $stmt = $dbh->prepare($query);
                $stmt->execute($imageIds);
                // until now, it's been fast.  fetch() is the slow part
                while ($row = $stmt->fetch()) {
                    $rows[] = $row;
                }
                

                推薦答案

                確保您告訴 PDO 該值是整數(shù)而不是字符串;如果 PDO 把它作為一個字符串,那么 MySQL 將不得不對這些值進行類型轉(zhuǎn)換以進行比較.根據(jù)它的處理方式,它可能會導(dǎo)致 MySQL 避免使用索引,從而導(dǎo)致嚴重的減速.

                Make sure you're telling PDO that the value is an integer not a string; if PDO puts it as a string, then MySQL will have to typecast the values for comparison. Depending on how it goes about this, it could cause major slowdowns by causing MySQL to avoid using an index.

                我不完全確定這里的行為,但幾年前我在 Postgres 上遇到過這個問題......

                I'm not completely sure about the behaviour here, but I have had this problem with Postgres a few years back...

                這篇關(guān)于為什么在 PHP 和 MySQL 中使用 PDO 的某些類型的準備查詢很慢?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環(huán))
                Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務(wù)器還是從同一用戶獲取記錄?)
                PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數(shù))
                Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結(jié)果填充變量)
                MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“l(fā)ocalhost的訪問被拒絕)

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

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

                        • 主站蜘蛛池模板: 拍真实国产伦偷精品 | 日韩黄色小视频 | a级免费黄色片 | 成人福利影院 | 日p视频免费看 | 日韩精品一二三 | 蜜桃视频在线观看免费视频网站www | 99精品欧美一区二区三区 | www.久草.com| 成人无遮挡毛片免费看 | 成人影院一区二区三区 | 久久久久国产一区二区三区四区 | 国产二区在线播放 | 久久久久久久91 | 九九热这里 | 国产精品美女www爽爽爽视频 | 国产精品久久精品 | 在线视频一区二区 | 在线国产一区 | 日韩视频精品 | 99re视频在线免费观看 | 国产精品久久久久久影视 | 四虎最新| 国产第一页在线播放 | 国产成人精品综合 | 五月综合久久 | 岛国精品| 久99久视频| 操操日| 日韩精品久久久久久 | 国产网站在线免费观看 | 亚洲免费视频网站 | 国产真实精品久久二三区 | 久久夜视频 | 精品国模一区二区三区欧美 | 色橹橹欧美在线观看视频高清 | 亚洲久久 | 成人片免费看 | 国产福利观看 | 激情a| 91精品久久久久久久久久 |