当前位置:网站首页>Tidb execution plan -- II

Tidb execution plan -- II

2022-06-13 06:49:00 Lao Wang's notes

  • Convergence class operator
    • Hash Aggregate
      • Blocking execution , Only after the whole calculation is completed can the result be output to the upper operator
      • There's no need to sort in advance
      • Support parallel
      • Large memory consumption
      • mysql> explain select /*+HASH_AGG()*/ count(1) from student; 
        +---------------------------+-----------+-----------+----------------------------------+---------------------------------+
        | id                        | estRows   | task      | access object                    | operator info                   |
        +---------------------------+-----------+-----------+----------------------------------+---------------------------------+
        | HashAgg_10                | 1.00      | root      |                                  | funcs:count(Column#7)->Column#5 |
        | └─IndexReader_11          | 1.00      | root      |                                  | index:HashAgg_5                 |
        |   └─HashAgg_5             | 1.00      | cop[tikv] |                                  | funcs:count(1)->Column#7        |
        |     └─IndexFullScan_9     | 100185.00 | cop[tikv] | table:student, index:PRIMARY(id) | keep order:false                |
        +---------------------------+-----------+-----------+----------------------------------+---------------------------------+
        4 rows in set (0.00 sec)
        

    • Stream Aggregate
      • Non blocking , A row of results can be calculated to return a pair of limit Friendly operation
      • Memory usage is small
      • Single thread execution
      • You need to sort ahead
      • mysql> explain select /*+STREAM_AGG()*/ count(1) from student;    
        +----------------------------+-----------+-----------+----------------------------------+---------------------------------+
        | id                         | estRows   | task      | access object                    | operator info                   |
        +----------------------------+-----------+-----------+----------------------------------+---------------------------------+
        | StreamAgg_15               | 1.00      | root      |                                  | funcs:count(Column#7)->Column#5 |
        | └─IndexReader_16           | 1.00      | root      |                                  | index:StreamAgg_8               |
        |   └─StreamAgg_8            | 1.00      | cop[tikv] |                                  | funcs:count(1)->Column#7        |
        |     └─IndexFullScan_14     | 100185.00 | cop[tikv] | table:student, index:PRIMARY(id) | keep order:false                |
        +----------------------------+-----------+-----------+----------------------------------+---------------------------------+

  • Scan data operator
    • Point Get/ Batch Point Get: Check , The fastest , Optimal operator , There is no need to execute the plan ;
    • Table Reader
      • Full table scan , No index ; TableFullScan
    • Index Reader
      • You don't have to go back to the table , Index reading
    • Index Lookup Reader
      • Go to the index , We need to go back to the table ;
    • Index Merge Reader
      • 4.0 After the introduction of , You can use multiple indexes in one table , Merge the results ;
  • Table join operator
    • Hash Join
      • Put a table with a smaller result set into memory , do HASH, With HASH Tables are associated ;
      • The two associated tables can only be equivalent queries
      • Multithreading
    • Merge Join
      • Sort the table first , Then connect the tables
      • If the amount of data is large , It can be put into memory in batches for orderly table connection
      • Than Hash Join To save memory ;
      • Single thread
    • Index Join
      • Table to table connection ;
      • Parallel thread
      • Each batch match ;
    • Index Hash Join
      • Convert connected objects from tables to indexes ;
原网站

版权声明
本文为[Lao Wang's notes]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202270551122293.html

随机推荐