日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
MYSQLorderby排序?qū)е滦实托?yōu)化

MYSQL order by排序?qū)е滦实托?yōu)化

創(chuàng)新互聯(lián)建站專業(yè)提供成都主機(jī)托管四川主機(jī)托管成都服務(wù)器托管四川服務(wù)器托管,支持按月付款!我們的承諾:貴族品質(zhì)、平民價格,機(jī)房位于中國電信/網(wǎng)通/移動機(jī)房,電信機(jī)房托管服務(wù)有保障!

有一個主表left join 同一個小表兩次分頁語句,因為order by 導(dǎo)致執(zhí)行時做排序,從執(zhí)行計劃中Using filesort ,以及profile中creating sort index 耗時可以看出。

MYSQL order by排序?qū)е滦实托?yōu)化

MYSQL order by排序?qū)е滦实托?yōu)化

從trace文件可以看出filesort的計算:

"join_execution": {
        "select#": 1,
        "steps": [
          {
            "filesort_information": [
              {
                "direction": "desc",
                "table": "`topxxx` `t`",
                "field": "create_date"
              }
            ] /* filesort_information */,
            "filesort_priority_queue_optimization": {
              "limit": 20,
              "rows_estimate": 2302749,
              "row_size": 264,
              "memory_available": 4194304,
              "chosen": true
            } /* filesort_priority_queue_optimization */,
            "filesort_execution": [
            ] /* filesort_execution */,
            "filesort_summary": {
              "rows": 21,
              "examined_rows": 216594,
              "number_of_tmp_files": 0,
              "sort_buffer_size": 5712,
              "sort_mode": ""
            } /* filesort_summary */
          }
        ] /* steps */
      } /* join_execution */
    }

后面通過索引加入排序字段后減去排序操作,排序字段放在索引的最前面。

create index idx_topxxx1 on topic (create_date desc,is_del,is_en);

MYSQL order by排序?qū)е滦实托?yōu)化

trace 中可以看出排序使用了索引。

            "reconsidering_access_paths_for_index_ordering": {
              "clause": "ORDER BY",
              "index_order_summary": {
                "table": "`topic` `t`",
                "index_provides_order": true,
                "order_direction": "desc",
                "index": "idx_topxxx1",
                "plan_changed": true,
                "access_type": "index"
              } /* index_order_summary */
            } /* reconsidering_access_paths_for_index_ordering */
          },
          {

以此記錄。


新聞標(biāo)題:MYSQLorderby排序?qū)е滦实托?yōu)化
文章鏈接:http://www.dlmjj.cn/article/gdcpoh.html