主頁 > 資料庫 > MySql中執行計劃如何來的——Optimizer Trace

MySql中執行計劃如何來的——Optimizer Trace

2023-04-27 08:47:38 資料庫

作者:京東物流 籍磊

1.前言

當談到MySQL的執行計劃時,會有很多同學想:“我就覺得使用其他的執行方案比EXPLAIN陳述句輸出的方案強,憑什么優化器做的決定與我得不一樣?”,這個問題在MySQL 5.6之前或許自己很難解決,但是現在MySQL5.6及更高的版本中引入了Optimizer Trace,

2.optimizer_trace開啟方式及表結構

當下面這行代碼執行的時候會將會使用戶能夠方便地查看優化器生成執行計劃的整個程序,

SET SESSION optimizer_trace=”enabled=on”;

optimizer_trace的開關默認是關閉的,我們可以使用下行代碼查看optimizer_trace狀態,

SHOW variables LIKE'optimizer_trace';

其中one_line值是用來控制輸出格式的,如果值為on,那所有的資訊會在同一行中展示(這樣并不便于我們閱讀),默認為off,當我們的optimizer_trace的enabled為on時,輸入想要查看優化程序的查詢陳述句,在該陳述句執行完之后,就可以到information_schema資料庫下的optimizer_trace表中查看詳細的執行計劃生成程序,當然也可以直接對想要的查詢陳述句使用EXPLAIN,

optimizer_trace表有四列,每列注釋我補充在下方create陳述句中:

CREATE TEMPORARY TABLE `OPTIMIZER_TRACE` (
  `QUERY` longtext NOT NULL COMMENT '我們輸入的查詢陳述句',
  `TRACE` longtext NOT NULL COMMENT '優化程序的json文本',
  `MISSING_BYTES_BEYOND_MAX_MEM_SIZE` int(20) NOT NULL DEFAULT '0' COMMENT '執行計劃生成
的程序中產生的超出字數限制的文本數',
  `INSUFFICIENT_PRIVILEGES` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否有權限查看執行
計劃的生成程序,0有權限,1無權限'
) ENGINE=InnoDB DEFAULT CHARSET=utf8

3.optimizer_trace實踐

我們現在根據一個例子來看看optimizer_trace的實踐,

explain select * from ship_data.check_table 
where 
outbound_no ='ESL48400163536608' and 
yn=0 and 
update_user ='jilei18';
SELECT * FROM information_schema.OPTIMIZER_TRACE;

上述sql的執行計劃如下:

OPTIMIZER_TRACE表中的資訊,這里可以注意到MISSING_BYTES_BEYOND_MAX_MEM_SIZE的值為1023,說明TRACE中并沒有顯示出全部的優化程序:

Query列中的文本是我們執行的Sql陳述句:

/* ApplicationName=DBeaver 21.1.3 - SQLEditor <Script-2.sql> */ explain select * from ship_data.check_table 
where 
outbound_no ='ESL48400163536608' and 
yn=0 and 
update_user ='jilei18'

TRACE列是優化的具體程序,其中分析程序需要注意的點在下面代碼框中使用#注釋的形式給出:

{
  "steps": [
    {
      "join_preparation": { #prepare階段
        "select#": 1,
        "steps": [
          {
            "expanded_query": "/* select#1 */ select `ship_data`.`check_table`.`m_id` AS `m_id`,`ship_data`.`check_table`.`wave_no` AS `wave_no`,`ship_data`.`check_table`.`wave_type` AS `wave_type`,`ship_data`.`check_table`.`outbound_no` AS `outbound_no`,`ship_data`.`check_table`.`outbound_type` AS `outbound_type`,`ship_data`.`check_table`.`check_type` AS `check_type`,`ship_data`.`check_table`.`production_mode` AS `production_mode`,`ship_data`.`check_table`.`sku_qty` AS `sku_qty`,`ship_data`.`check_table`.`total_qty` AS `total_qty`,`ship_data`.`check_table`.`uncheck_qty` AS `uncheck_qty`,`ship_data`.`check_table`.`container_no` AS `container_no`,`ship_data`.`check_table`.`production_wave_no` AS `production_wave_no`,`ship_data`.`check_table`.`carriage_no` AS `carriage_no`,`ship_data`.`check_table`.`realcarriage_no` AS `realcarriage_no`,`ship_data`.`check_table`.`case_no` AS `case_no`,`ship_data`.`check_table`.`rebinwall_no` AS `rebinwall_no`,`ship_data`.`check_table`.`locate_sum_qty` AS `locate_sum_qty`,`ship_data`.`check_table`.`check_differ_qty_small` AS `check_differ_qty_small`,`ship_data`.`check_table`.`supplier_code` AS `supplier_code`,`ship_data`.`check_table`.`supplier_name` AS `supplier_name`,`ship_data`.`check_table`.`broke_type` AS `broke_type`,`ship_data`.`check_table`.`outbound_level` AS `outbound_level`,`ship_data`.`check_table`.`outbound_time` AS `outbound_time`,`ship_data`.`check_table`.`sort_entry` AS `sort_entry`,`ship_data`.`check_table`.`end_time` AS `end_time`,`ship_data`.`check_table`.`end_time_attr` AS `end_time_attr`,`ship_data`.`check_table`.`send_address` AS `send_address`,`ship_data`.`check_table`.`site_no` AS `site_no`,`ship_data`.`check_table`.`site_name` AS `site_name`,`ship_data`.`check_table`.`sort_slot_no` AS `sort_slot_no`,`ship_data`.`check_table`.`valueadd_flag` AS `valueadd_flag`,`ship_data`.`check_table`.`package_qty` AS `package_qty`,`ship_data`.`check_table`.`send_type` AS `send_type`,`ship_data`.`check_table`.`resource` AS `resource`,`ship_data`.`check_table`.`platform_no` AS `platform_no`,`ship_data`.`check_table`.`pack_table_no` AS `pack_table_no`,`ship_data`.`check_table`.`total_weight` AS `total_weight`,`ship_data`.`check_table`.`total_volume` AS `total_volume`,`ship_data`.`check_table`.`status` AS `status`,`ship_data`.`check_table`.`status_lock` AS `status_lock`,`ship_data`.`check_table`.`cancel_order_status` AS `cancel_order_status`,`ship_data`.`check_table`.`is_shortage` AS `is_shortage`,`ship_data`.`check_table`.`check_num` AS `check_num`,`ship_data`.`check_table`.`multiple_check` AS `multiple_check`,`ship_data`.`check_table`.`org_no` AS `org_no`,`ship_data`.`check_table`.`distribute_no` AS `distribute_no`,`ship_data`.`check_table`.`warehouse_no` AS `warehouse_no`,`ship_data`.`check_table`.`create_user` AS `create_user`,`ship_data`.`check_table`.`create_time` AS `create_time`,`ship_data`.`check_table`.`update_user` AS `update_user`,`ship_data`.`check_table`.`update_time` AS `update_time`,`ship_data`.`check_table`.`yn` AS `yn`,`ship_data`.`check_table`.`OWNER_NO` AS `OWNER_NO`,`ship_data`.`check_table`.`OWNER_NAME` AS `OWNER_NAME`,`ship_data`.`check_table`.`batch_no` AS `batch_no`,`ship_data`.`check_table`.`check_business_tag` AS `check_business_tag`,`ship_data`.`check_table`.`group_no` AS `group_no`,`ship_data`.`check_table`.`TRIAL_PRODUCT_FLAG` AS `TRIAL_PRODUCT_FLAG`,`ship_data`.`check_table`.`CHECK_MODE` AS `CHECK_MODE`,`ship_data`.`check_table`.`check_differ_qty_total` AS `check_differ_qty_total`,`ship_data`.`check_table`.`check_differ_qty_medium` AS `check_differ_qty_medium`,`ship_data`.`check_table`.`picking_finished` AS `picking_finished`,`ship_data`.`check_table`.`cell_no` AS `cell_no`,`ship_data`.`check_table`.`rebin_no` AS `rebin_no`,`ship_data`.`check_table`.`status_picking` AS `status_picking`,`ship_data`.`check_table`.`status_picking_small` AS `status_picking_small`,`ship_data`.`check_table`.`status_picking_medium` AS `status_picking_medium`,`ship_data`.`check_table`.`status_small` AS `status_small`,`ship_data`.`check_table`.`status_medium` AS `status_medium`,`ship_data`.`check_table`.`picking_time` AS `picking_time`,`ship_data`.`check_table`.`isv_outstore_no` AS `isv_outstore_no`,`ship_data`.`check_table`.`pick_type` AS `pick_type`,`ship_data`.`check_table`.`sf_ship_no` AS `sf_ship_no`,`ship_data`.`check_table`.`isCollectDeliveryInfo` AS `isCollectDeliveryInfo`,`ship_data`.`check_table`.`expect_package_qty` AS `expect_package_qty`,`ship_data`.`check_table`.`print_shopping_flag` AS `print_shopping_flag`,`ship_data`.`check_table`.`product_mode_flag` AS `product_mode_flag`,`ship_data`.`check_table`.`schedulebill_code` AS `schedulebill_code`,`ship_data`.`check_table`.`uppershelf_time` AS `uppershelf_time`,`ship_data`.`check_table`.`mixedorder_type` AS `mixedorder_type`,`ship_data`.`check_table`.`child_order_flag` AS `child_order_flag`,`ship_data`.`check_table`.`inbound_no` AS `inbound_no`,`ship_data`.`check_table`.`production_order_no` AS `production_order_no`,`ship_data`.`check_table`.`check_user` AS `check_user`,`ship_data`.`check_table`.`check_finish_time` AS `check_finish_time`,`ship_data`.`check_table`.`check_style` AS `check_style` from `ship_data`.`check_table` where ((`ship_data`.`check_table`.`outbound_no` = 'ESL48400163536608') and (`ship_data`.`check_table`.`yn` = 0) and (`ship_data`.`check_table`.`update_user` = 'jilei18'))"
          }
        ]
      }
    },
    {
      "join_optimization": { #optimize階段
        "select#": 1,
        "steps": [
          {
            "condition_processing": {#處理搜索條件
              "condition": "WHERE",
              "original_condition": "((`ship_data`.`check_table`.`outbound_no` = 'ESL48400163536608') and (`ship_data`.`check_table`.`yn` = 0) and (`ship_data`.`check_table`.`update_user` = 'jilei18'))",
              "steps": [
                {
                  "transformation": "equality_propagation",#處理等值轉換
                  "resulting_condition": "((`ship_data`.`check_table`.`outbound_no` = 'ESL48400163536608') and (`ship_data`.`check_table`.`update_user` = 'jilei18') and multiple equal(0, `ship_data`.`check_table`.`yn`))"
                },
                {
                  "transformation": "constant_propagation",#常量傳遞轉換
                  "resulting_condition": "((`ship_data`.`check_table`.`outbound_no` = 'ESL48400163536608') and (`ship_data`.`check_table`.`update_user` = 'jilei18') and multiple equal(0, `ship_data`.`check_table`.`yn`))"
                },
                {
                  "transformation": "trivial_condition_removal",#去除沒用的條件
                  "resulting_condition": "((`ship_data`.`check_table`.`outbound_no` = 'ESL48400163536608') and (`ship_data`.`check_table`.`update_user` = 'jilei18') and multiple equal(0, `ship_data`.`check_table`.`yn`))"
                }
              ]
            }
          },
          {
            "substitute_generated_columns": {#去除虛擬生成的列
            }
          },
          {
            "table_dependencies": [#表的依賴資訊
              {
                "table": "`ship_data`.`check_table`",
                "row_may_be_null": false,
                "map_bit": 0,
                "depends_on_map_bits": [
                ]
              }
            ]
          },
          {
            "ref_optimizer_key_uses": [#列出所有可用的ref型別的索引
              {
                "table": "`ship_data`.`check_table`",
                "field": "outbound_no",
                "equals": "'ESL48400163536608'",
                "null_rejecting": false
              }
            ]
          },
          {
            "rows_estimation": [#預估不同單表訪問方法的訪問成本
              {
                "table": "`ship_data`.`check_table`",
                "range_analysis": {
                  "table_scan": {#全表掃描的行數及成本
                    "rows": 79745,
                    "cost": 19127
                  },
                  "potential_range_indexes": [#分析可能使用的索引,此處就是執行計劃中的possiable_keys
                    {
                      "index": "PRIMARY",#主鍵不可用
                      "usable": false,
                      "cause": "not_applicable"
                    },
                    {
                      "index": "UK_batch_production",#UK_batch_production索引不可用
                      "usable": false,
                      "cause": "not_applicable"
                    },
                    {
                      "index": "idx_update_time",#idx_update_time索引不可用
                      "usable": false,
                      "cause": "not_applicable"
                    },
                    {
                      "index": "IDX_status",#IDX_status索引不可用
                      "usable": false,
                      "cause": "not_applicable"
                    },
                    {
                      "index": "idx_case_no",#idx_case_no索引不可用
                      "usable": false,
                      "cause": "not_applicable"
                    },
                    {
                      "index": "idx_outbound_time",#idx_outbound_time索引不可用
                      "usable": false,
                      "cause": "not_applicable"
                    },
                    {
                      "index": "idx_outboundno",#idx_outboundno索引可用
                      "usable": true,
                      "key_parts": [
                        "outbound_no",
                        "m_id"
                      ]
                    },
                    {
                      "index": "idx_wave_no",#idx_wave_no索引不可用
                      "usable": false,
                      "cause": "not_applicable"
                    },
                    {
                      "index": "idx_cancel_order_status",#idx_cancel_order_status索引不可用
                      "usable": false,
                      "cause": "not_applicable"
                    },
                    {
                      "index": "idx_production_wave_no",#idx_production_wave_no索引不可用
                      "usable": false,
                      "cause": "not_applicable"
                    },
                    {
                      "index": "idx_schedulebillcode_uppershelftime",#idx_schedulebillcode_uppershelftime索引不可用
                      "usable": false,
                      "cause": "not_applicable"
                    },
                    {
                      "index": "idx_production_orderno",#idx_production_orderno索引不可用
                      "usable": false,
                      "cause": "not_applicable"
                    },
                    {
                      "index": "idx_end_time_attr",#idx_end_time_attr索引不可用
                      "usable": false,
                      "cause": "not_applicable"
                    }
                  ],
                  "setup_range_conditions": [
                  ],
                  "group_index_range": {
                    "chosen": false,
                    "cause": "not_group_by_or_distinct"
                  },
                  "analyzing_range_alternatives": {#分析可能使用的索引的成本
                    "range_scan_alternatives": [
                      {
                        "index": "idx_outboundno",#使用idx_outboundno索引的成本
                        "ranges": [
                          "ESL48400163536608 <= outbound_no <= ESL48400163536608"
                        ],
                        "index_dives_for_eq_ranges": true,#是否使用index_dives
                        "rowid_ordered": true,#使用該索引獲取的記錄是否按照主鍵排序
                        "using_mrr": false,#是否使用mrr
                        "index_only": false,#是否是覆寫索引
                        "rows": 1,#使用該索引獲取的記錄條數
                        "cost": 2.21,#使用該索引花費的成本
                        "chosen": true#是否選擇該索引
                        "cause": "cost"#該欄位為作者添加,當有索引未被使用時會標記未被使用的原因,cost為成本不合理未被選用
                      }
                    ],
                    "analyzing_roworder_intersect": {#分析使用索引合并的成本
                      "usable": false,
                      "cause": "too_few_roworder_scans"
                    }
                  },
                  "chosen_range_access_summary": {#對于上述單表查詢check_table最優的方法
                    "range_access_plan": {
                      "type": "range_scan",
                      "index": "idx_outboundno",
                      "rows": 1,
                      "ranges": [
                        "ESL48400163536608 <= outbound_no <= ESL48400163536608"
                      ]
                    },
                    "rows_for_plan": 1,
                    "cost_for_plan": 2.21,
                    "chosen": true
                  }
                }
              }
            ]
          },
          {
            "considered_execution_plans": [#分析各種可能的執行計劃
              {
                "plan_prefix": [
                ],
                "table": "`ship_data`.`check_table`",
                "best_access_path": {
                  "considered_access_paths": [
                    {
                      "access_type": "ref",
                      "index": "idx_outboundno",
                      "rows": 1,
                      "cost": 1.2,
                      "chosen": true
                    },
                    {
                      "access_type": "range",
                      "range_details": {
                        "used_index": "idx_outboundno"
                      },
                      "chosen": false,
                      "cause": "heuristic_index_cheaper"
                    }
                  ]
                },
                "condition_filtering_pct": 5,#下面的資料來自官網示例,作者示例中超出長度的文本無法獲取到
                "rows_for_plan": 0.05,
                                        "cost_for_plan": 8.55,
                                        "chosen": true
                                    }
                                ] /* rest_of_plan */
                            }
                        ] /* considered_execution_plans */
                    },
                    {
                        "attaching_conditions_to_tables": {#嘗試給查詢添加一些其他的查詢條件
                            "original_condition": "((`alias2`.`pk` = `alias1`.`col_int_key`) and (0 <> `alias1`.`pk`))",
                            "attached_conditions_computation": [] /* attached_conditions_computation */,
                            "attached_conditions_summary": [
                                {
                                    "table": "`t1` `alias1`",
                                    "attached": "((0 <> `alias1`.`pk`) and (`alias1`.`col_int_key` is not null))"
                                },
                                {
                                    "table": "`t2` `alias2`",
                                    "attached": "(`alias2`.`pk` = `alias1`.`col_int_key`)"
                                }
                            ] /* attached_conditions_summary */
                        } /* attaching_conditions_to_tables */
                    },
                    {
                        "optimizing_distinct_group_by_order_by": {
                            "simplifying_order_by": {
                                "original_clause": "`alias1`.`col_int_key`,`alias2`.`pk`",
                                "items": [
                                    {
                                        "item": "`alias1`.`col_int_key`"
                                    },
                                    {
                                        "item": "`alias2`.`pk`",
                                        "eq_ref_to_preceding_items": true
                                    }
                                ] /* items */,
                                "resulting_clause_is_simple": true,
                                "resulting_clause": "`alias1`.`col_int_key`"
                            } /* simplifying_order_by */,
                            "simplifying_group_by": {
                                "original_clause": "`field2`",
                                "items": [
                                    {
                                        "item": "`alias2`.`pk`"
                                    }
                                ] /* items */,
                                "resulting_clause_is_simple": false,
                                "resulting_clause": "`field2`"
                            } /* simplifying_group_by */
                        } /* optimizing_distinct_group_by_order_by */
                    },
                    {
                        "finalizing_table_conditions": [
                            {
                                "table": "`t1` `alias1`",
                                "original_table_condition": "((0 <> `alias1`.`pk`) and (`alias1`.`col_int_key` is not null))",
                                "final_table_condition   ": "((0 <> `alias1`.`pk`) and (`alias1`.`col_int_key` is not null))"
                            },
                            {
                                "table": "`t2` `alias2`",
                                "original_table_condition": "(`alias2`.`pk` = `alias1`.`col_int_key`)",
                                "final_table_condition   ": null
                            }
                        ] /* finalizing_table_conditions */
                    },
                    {
                        "refine_plan": [#再稍加改進執行計劃
                            {
                                "table": "`t1` `alias1`"
                            },
                            {
                                "table": "`t2` `alias2`"
                            }
                        ] /* refine_plan */
                    },
                    {
                        "considering_tmp_tables": [
                            {
                                "adding_tmp_table_in_plan_at_position": 2,
                                "write_method": "continuously_update_group_row"
                            },
                            {
                                "adding_sort_to_table": ""
                            } /* filesort */
                        ] /* considering_tmp_tables */
                    }
                ] /* steps */
            } /* join_optimization */
        },
        {
            "join_execution": {#execute階段
                "select#": 1,
                "steps": [
                    {
                        "temp_table_aggregate": {
                            "select#": 1,
                            "steps": [
                                {
                                    "creating_tmp_table": {
                                        "tmp_table_info": {
                                            "in_plan_at_position": 2,
                                            "columns": 3,
                                            "row_length": 18,
                                            "key_length": 4,
                                            "unique_constraint": false,
                                            "makes_grouped_rows": true,
                                            "cannot_insert_duplicates": false,
                                            "location": "TempTable"
                                        } /* tmp_table_info */
                                    } /* creating_tmp_table */
                                }
                            ] /* steps */
                        } /* temp_table_aggregate */
                    },
                    {
                        "sorting_table": "<temporary>",
                        "filesort_information": [
                            {
                                "direction": "asc",
                                "expression": "`alias1`.`col_int_key`"
                            }
                        ] /* filesort_information */,
                        "filesort_priority_queue_optimization": {
                            "usable": false,
                            "cause": "not applicable (no LIMIT)"
                        } /* filesort_priority_queue_optimization */,
                        "filesort_execution": [] /* filesort_execution */,
                        "filesort_summary": {
                            "memory_available": 262144,
                            "key_size": 9,
                            "row_size": 26,
                            "max_rows_per_buffer": 7710,
                            "num_rows_estimate": 18446744073709551615,
                            "num_rows_found": 8,
                            "num_initial_chunks_spilled_to_disk": 0,
                            "peak_memory_used": 32840,
                            "sort_algorithm": "std::sort",
                            "unpacked_addon_fields": "skip_heuristic",
                            "sort_mode": "<fixed_sort_key, additional_fields>"
                        } /* filesort_summary */
                    }
                ] /* steps */
            } /* join_execution */
        }
    ] /* steps */
}

4.總結

上述內容大致分為三個階段:prepare階段、optimize階段、execute階段,MySQL中基于成本的優化主要在optimize階段,在單表查詢時會主要關注optimize階段的rows_estimation程序,這個rows_estimation程序分析了多種執行方案的成本耗費,在多表連接查詢的時候,我們更多關注considered_execution_plans程序,不過總而言之查詢優化器最侄訓選擇成本最低的方案來作為最終的執行計劃,即我們使用EXPLAIN陳述句時顯示出的方案,

轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/551344.html

標籤:MySQL

上一篇:MYSQL SQL查詢近7天,一個月的資料

下一篇:返回列表

標籤雲
其他(158221) Python(38107) JavaScript(25395) Java(18001) C(15217) 區塊鏈(8260) C#(7972) AI(7469) 爪哇(7425) MySQL(7150) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5870) 数组(5741) R(5409) Linux(5329) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4562) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2431) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1960) Web開發(1951) HtmlCss(1928) python-3.x(1918) 弹簧靴(1913) C++(1912) xml(1889) PostgreSQL(1874) .NETCore(1855) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • GPU虛擬機創建時間深度優化

    **?桔妹導讀:**GPU虛擬機實體創建速度慢是公有云面臨的普遍問題,由于通常情況下創建虛擬機屬于低頻操作而未引起業界的重視,實際生產中還是存在對GPU實體創建時間有苛刻要求的業務場景。本文將介紹滴滴云在解決該問題時的思路、方法、并展示最終的優化成果。 從公有云服務商那里購買過虛擬主機的資深用戶,一 ......

    uj5u.com 2020-09-10 06:09:13 more
  • 可編程網卡芯片在滴滴云網路的應用實踐

    **?桔妹導讀:**隨著云規模不斷擴大以及業務層面對延遲、帶寬的要求越來越高,采用DPDK 加速網路報文處理的方式在橫向縱向擴展都出現了局限性。可編程芯片成為業界熱點。本文主要講述了可編程網卡芯片在滴滴云網路中的應用實踐,遇到的問題、帶來的收益以及開源社區貢獻。 #1. 資料中心面臨的問題 隨著滴滴 ......

    uj5u.com 2020-09-10 06:10:21 more
  • 滴滴資料通道服務演進之路

    **?桔妹導讀:**滴滴資料通道引擎承載著全公司的資料同步,為下游實時和離線場景提供了必不可少的源資料。隨著任務量的不斷增加,資料通道的整體架構也隨之發生改變。本文介紹了滴滴資料通道的發展歷程,遇到的問題以及今后的規劃。 #1. 背景 資料,對于任何一家互聯網公司來說都是非常重要的資產,公司的大資料 ......

    uj5u.com 2020-09-10 06:11:05 more
  • 滴滴AI Labs斬獲國際機器翻譯大賽中譯英方向世界第三

    **桔妹導讀:**深耕人工智能領域,致力于探索AI讓出行更美好的滴滴AI Labs再次斬獲國際大獎,這次獲獎的專案是什么呢?一起來看看詳細報道吧! 近日,由國際計算語言學協會ACL(The Association for Computational Linguistics)舉辦的世界最具影響力的機器 ......

    uj5u.com 2020-09-10 06:11:29 more
  • MPP (Massively Parallel Processing)大規模并行處理

    1、什么是mpp? MPP (Massively Parallel Processing),即大規模并行處理,在資料庫非共享集群中,每個節點都有獨立的磁盤存盤系統和記憶體系統,業務資料根據資料庫模型和應用特點劃分到各個節點上,每臺資料節點通過專用網路或者商業通用網路互相連接,彼此協同計算,作為整體提供 ......

    uj5u.com 2020-09-10 06:11:41 more
  • 滴滴資料倉庫指標體系建設實踐

    **桔妹導讀:**指標體系是什么?如何使用OSM模型和AARRR模型搭建指標體系?如何統一流程、規范化、工具化管理指標體系?本文會對建設的方法論結合滴滴資料指標體系建設實踐進行解答分析。 #1. 什么是指標體系 ##1.1 指標體系定義 指標體系是將零散單點的具有相互聯系的指標,系統化的組織起來,通 ......

    uj5u.com 2020-09-10 06:12:52 more
  • 單表千萬行資料庫 LIKE 搜索優化手記

    我們經常在資料庫中使用 LIKE 運算子來完成對資料的模糊搜索,LIKE 運算子用于在 WHERE 子句中搜索列中的指定模式。 如果需要查找客戶表中所有姓氏是“張”的資料,可以使用下面的 SQL 陳述句: SELECT * FROM Customer WHERE Name LIKE '張%' 如果需要 ......

    uj5u.com 2020-09-10 06:13:25 more
  • 滴滴Ceph分布式存盤系統優化之鎖優化

    **桔妹導讀:**Ceph是國際知名的開源分布式存盤系統,在工業界和學術界都有著重要的影響。Ceph的架構和演算法設計發表在國際系統領域頂級會議OSDI、SOSP、SC等上。Ceph社區得到Red Hat、SUSE、Intel等大公司的大力支持。Ceph是國際云計算領域應用最廣泛的開源分布式存盤系統, ......

    uj5u.com 2020-09-10 06:14:51 more
  • es~通過ElasticsearchTemplate進行聚合~嵌套聚合

    之前寫過《es~通過ElasticsearchTemplate進行聚合操作》的文章,這一次主要寫一個嵌套的聚合,例如先對sex集合,再對desc聚合,最后再對age求和,共三層嵌套。 Aggregations的部分特性類似于SQL語言中的group by,avg,sum等函式,Aggregation ......

    uj5u.com 2020-09-10 06:14:59 more
  • 爬蟲日志監控 -- Elastc Stack(ELK)部署

    傻瓜式部署,只需替換IP與用戶 導讀: 現ELK四大組件分別為:Elasticsearch(核心)、logstash(處理)、filebeat(采集)、kibana(可視化) 下載均在https://www.elastic.co/cn/downloads/下tar包,各組件版本最好一致,配合fdm會 ......

    uj5u.com 2020-09-10 06:15:05 more
最新发布
  • MySql中執行計劃如何來的——Optimizer Trace

    當談到MySQL的執行計劃時,會有很多同學想:“我就覺得使用其他的執行方案比EXPLAIN陳述句輸出的方案強,憑什么優化器做的決定與我得不一樣?”。這個問題在MySQL 5.6之前或許自己很難解決,但是現在MySQL5.6及更高的版本中引入了Optimizer Trace。 ......

    uj5u.com 2023-04-27 08:47:38 more
  • MYSQL SQL查詢近7天,一個月的資料

    //今天 select * from 表名 where to_days(時間欄位名) = to_days(now()); //昨天 SELECT * FROM 表名 WHERE TO_DAYS( NOW( ) ) - TO_DAYS( 時間欄位名) <= 1 //近7天 SELECT * FROM ......

    uj5u.com 2023-04-27 08:47:33 more
  • day06-優惠券秒殺02

    功能03-優惠券秒殺02 4.功能03-優惠券秒殺 4.4一人一單 4.4.1需求分析 要求:修改秒殺業務,要求同一個優惠券,一個用戶只能下一單。 在之前的做法中,加入一個對用戶id和優惠券id的判斷,如果在優惠券下單表中已經存在,則表示該用戶對于這張優惠券已經下過單了,不允許重復購買 4.4.2代 ......

    uj5u.com 2023-04-26 08:26:12 more
  • 分析查詢陳述句:EXPLAIN

    一、概述 使用mysqldumpslow工具定位到慢查詢陳述句之后,可以使用explain或describe工具做針對性的分析查詢陳述句。 MySQL種有專門負責優化SELECT陳述句的優化器模塊:通過計算分析系統中收集到的統計資訊,為客戶端請求的Query提供他認為最優的執行計劃。 這個執行計劃展示了接 ......

    uj5u.com 2023-04-26 08:24:58 more
  • 在Linux上安裝redis7

    1.檢測虛擬機環境 1.1 bit檢測命令:getconf LONG_BIT(建議使用64bit做開發) 1.2 gcc環境檢測:gcc -v 如果不具備gcc環境,則使用yum -y install gcc- c++命令進行c++環境的安裝 2.開始安裝 2.1 下載redis: 進入官網找到下載 ......

    uj5u.com 2023-04-26 08:24:16 more
  • Oracle中常用的系統表

    1、如何快速修改用戶中涉及多個表中某個欄位型別 1)方法一: SELECT 'alter table '||TABLE_NAME||' modify '||COLUMN_NAME||' VARCHAR2('||DATA_LENGTH||');' --要alter的sql ,T.* FROM dba_ ......

    uj5u.com 2023-04-26 08:23:58 more
  • 數倉實踐丨主動預防-DWS關鍵工具安裝確認

    摘要:gdb確認是否安裝,所帶來的該工具用戶資料庫實體觸發core問題后集群狀態反復例外,對此問題及時分析根因并及時進行規避。 本文分享自華為云社區《主動預防-DWS關鍵工具安裝確認》,作者:上官寒雨。 【關鍵工具確認】 1、gdb確認是否安裝(該工具用戶資料庫實體觸發core問題后集群狀態反復例外 ......

    uj5u.com 2023-04-26 08:23:49 more
  • 【Mysql】復合主鍵的索引

    復合主鍵在where中使用查詢的時候到底走不走索引呢?例如下表: create table index_test ( a int not null, b int not null, c int not null, d int null, primary key (a, b, c) ); 當執行以下S ......

    uj5u.com 2023-04-26 08:23:38 more
  • PostgreSQL插件那么多,怎樣管理最高效?

    摘要:華為云RDS for PostgreSQL通過插件管理功能,很好地解決了PostgreSQL版本與插件耦合的問題,幫助用戶更直觀、更快速地安裝管理資料庫插件。 本文分享自華為云社區《PostgreSQL插件那么多,怎樣管理最高效?》,作者:GaussDB 資料庫。 云服務環境下,如何讓客戶更方 ......

    uj5u.com 2023-04-26 08:23:26 more
  • elasticsearch 實作查詢忽略大小寫

    背景:在搜索的時候經常會有一種場景就是忽略大小寫,不管你輸入的是全大寫還是全小寫還是大小寫混合,希望都能夠搜索出結果。 解決思路:Elasticsearch中的lowercase normalizer將文本轉換為小寫,并將其作為規范形式存盤在索引中。這可以確保在搜索和比較文本時忽略大寫字母的差異,從 ......

    uj5u.com 2023-04-26 08:23:21 more