<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>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] # show profile 查看`profiling`系統變量 ~~~ruby mysql> show variables like '%profil%'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | have_profiling | YES | | profiling | OFF | | profiling_history_size | 15 | +------------------------+-------+ ~~~ * have\_profiling:當前版本是否支持`profiling`功能 * profiling:是否開啟`profiling`功能 * profiling\_history\_size:保留profiling的數目,默認是15,范圍為0~100,為0時代表禁用profiling 開啟profiling需要設置profiling變量為1,該變量的默認值是0 ~~~mysql mysql> SET profiling = 1; ~~~ 然后運行sql,查看下 ~~~ mysql> select sleep(3); +----------+ | sleep(3) | +----------+ | 0 | +----------+ 1 row in set (3.00 sec) mysql> show profiles; +----------+------------+-----------------+ | Query_ID | Duration | Query | +----------+------------+-----------------+ | 1 | 3.00183550 | select sleep(3) | +----------+------------+-----------------+ 1 row in set, 1 warning (0.00 sec) ~~~ 1. Query\_ID 表示執行SQL的唯一標識。 2. Duration 表示持續時間,默認單位為秒。 3. Query 就是我們所執行的SQL語句。 --- 1. show profiles 語句 默認顯示的是服務端接收到的最新的15條語句。 我們可以通過以下語句進行修改默認值: set profiling\_history\_size =20; profiling\_history\_size最大取值取值范圍為\[0,100\]。 2. 當超過100時,則會設置自動設置為最大值100。 3. 當小于0時,則會自動設置最小值為0。 4. 當其等于0時,其效果等同于`set profiling=0`,關閉性能分析模式。 ## 查sql 可以根據查詢的id去查詢 可以顯示更詳細的,指定資源查詢 ~~~ 語法:Show profile type , block type for query 問題sql數字號碼 ~~~ 其中type: * ALL: 顯示所有的開銷信息 * BLOCK IO : 顯示塊IO相關開銷 * CONTEXT SWITCHS: 上下文切換相關開銷 * CPU : 顯示cpu 相關開銷 * IPC: 顯示發送和接收相關開銷 * MEMORY: 顯示內存相關開銷 * PAGE FAULTS:顯示頁面錯誤相關開銷信息 * SOURCE : 顯示和Source\_function ,Source\_file,Source\_line 相關的開銷信息 * SWAPS:顯示交換次數相關的開銷信息 * Status : sql 語句執行的狀態 * Duration: sql 執行過程中每一個步驟的耗時 * CPU\_user: 當前用戶占有的cpu * CPU\_system: 系統占有的cpu * Block\_ops\_in : I/O 輸入 * Block\_ops\_out : I/O 輸出 ~~~ show profile block io,cpu for query 1; show profile cpu,block io,memory,swaps for query 1; show profile cpu,block io,memory,swaps,context switches,source for query 1; ~~~ ~~~ mysql> show profile for query 1; +----------------------+----------+ | Status | Duration | +----------------------+----------+ | starting | 0.000055 | | checking permissions | 0.000005 | | Opening tables | 0.000004 | | init | 0.000008 | | optimizing | 0.000004 | | executing | 0.000006 | | User sleep | 3.001711 | | end | 0.000010 | | query end | 0.000004 | | closing tables | 0.000003 | | freeing items | 0.000019 | | cleaning up | 0.000008 | +----------------------+----------+ 12 rows in set, 1 warning (0.00 sec) mysql> show profile block io,cpu for query 1; +----------------------+----------+----------+------------+--------------+---------------+ | Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out | +----------------------+----------+----------+------------+--------------+---------------+ | starting | 0.000055 | 0.000013 | 0.000035 | 0 | 0 | | checking permissions | 0.000005 | 0.000001 | 0.000004 | 0 | 0 | | Opening tables | 0.000004 | 0.000001 | 0.000002 | 0 | 0 | | init | 0.000008 | 0.000002 | 0.000006 | 0 | 0 | | optimizing | 0.000004 | 0.000001 | 0.000002 | 0 | 0 | | executing | 0.000006 | 0.000001 | 0.000005 | 0 | 0 | | User sleep | 3.001711 | 0.000126 | 0.000343 | 0 | 0 | | end | 0.000010 | 0.000002 | 0.000005 | 0 | 0 | | query end | 0.000004 | 0.000001 | 0.000003 | 0 | 0 | | closing tables | 0.000003 | 0.000001 | 0.000002 | 0 | 0 | | freeing items | 0.000019 | 0.000005 | 0.000014 | 0 | 0 | | cleaning up | 0.000008 | 0.000002 | 0.000006 | 0 | 0 | +----------------------+----------+----------+------------+--------------+---------------+ 12 rows in set, 1 warning (0.00 sec) ~~~ ## 各個字段含義 ~~~ show profile for query 1; ~~~ 1. all: 展示所有信息。 2. block io: 展示io的輸入輸出信息。 3. context switches: 展示線程的上線文切換信息。 4. cpu :顯示SQL 占用的CPU信息。 5. ipc: 顯示統計消息的發送與接收計數信息。 6. page faults:顯示主要與次要的頁面錯誤。 7. memory:本意是顯示內存信息,但目前還未實現。 8. swaps: 顯示交換次數。 9. sources:顯示源代碼中的函數名稱,以及函數發生的文件的名稱和行。 --- **一條query每個階段的資源開銷可以從`information_schema.profiling`表查詢** * state : 當前query所在的階段 * CPU_user : CPU用戶 * CPU_system : CPU系統 * Context_voluntary : 上下文主動切換 * Context_involuntary : 上下文被動切換 * Block_ops_in : 阻塞的輸入操作 * Block_ops_out : 阻塞的輸出操作 * Messages_sent : 消息發出 * Messages_received : 消息接受 * Page_faults_major : 主分頁錯誤 * Page_faults_minor : 次分頁錯誤 * Swaps : 交換次數 * Source_function : 源功能 * Source_file : 源文件 * Source_line : 源代碼行 --- 縱向(可以看到sql完整的生命周期): optimizing: 智能優化器 sending data: 發送數據 mysql文檔中字段含義: [https://dev.mysql.com/doc/refman/5.7/en/general-thread-states.html](https://dev.mysql.com/doc/refman/5.7/en/general-thread-states.html) ## 日常開發需要注意的 里面查出是這個要注意了 * converting HEAP to MyISAM : 查詢結果太大,內存都不夠用了,往磁盤上搬了; * creating tmp table :創建臨時表,拷貝數據到臨時表,然后再刪除; * copying to tmp table on disk :把內存中臨時表復制到磁盤,危險!!! * locked 注:以上四個中若出現一個或多個,表示sql 語句 必須優化。
                  <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>

                              哎呀哎呀视频在线观看