<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 優化OR條件 對于包含OR的查詢子句,如果要利用索引,則OR之間的每個條件列都必須用到索引 , 而且不能使用到復合索引; 如果沒有索引,則應該考慮增加索引。 獲取 emp 表中的所有的索引 : ~~~ show index from emp; ~~~ ![](https://img.kancloud.cn/08/08/0808bb12a5ae4fb4697a42d888fb2373_2802x294.png) 示例 : ```SQL explain select * from emp where id = 1 or age = 30; ``` ![](https://img.kancloud.cn/23/43/234326533e66a3d893ff23a4b530436d_2878x362.png) 建議使用union 替換or : ![](https://img.kancloud.cn/71/1e/711ea4e51dbd65bebb000593602703a7_2830x302.png) 我們來比較下重要指標,發現主要差別是 type 和 ref 這兩項,type 顯示的是訪問類型,是較為重要的一個指標,結果值從好到壞依次是: ``` system > const > eq_ref > ref > fulltext > ref_or_null > index_merge > unique_subquery > index_subquery > range > index > ALL ``` UNION 語句的 type 值為 ref,OR 語句的 type 值為 range,可以看到這是一個很明顯的差距 UNION 語句的 ref 值為 const,OR 語句的 type 值為 null,const 表示是常量值引用,非常快 這兩項的差距就說明了 UNION 要優于 OR
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看