一般的nested loop join都是把内存分为3块,一块用来存放较小的TABLE,一块用来存放较大TABLE的一部分,一块用来存放结果准备输出.
请问在MYSQL里的JOIN_BUFFER也是这么分的吗? 还是JOIN_BUFFER只负责存放JOIN的两个TABLE?
另外BUFFER分配的比例是怎么样了?
还想请教下SORT操作时SORT_BUFFER的分配是怎么样的呢?
最好能提供相关函数 谢谢

解决方案 »

  1.   

    mysql 设置join_buffer_size 才被应用Assume that a join between three tables t1, t2, and t3 is to be executed using the following join types: 
    Table   Join Type
    t1      range
    t2      ref
    t3      ALL
    If a simple NLJ algorithm is used, the join would be processed like this: 
    for each row in t1 matching range {
      for each row in t2 matching reference key {
        for each row in t3 {
          if row satisfies join conditions,
          send to client
        }
      }
    }
    Because the NLJ algorithm passes rows one at a time from outer loops to inner loops, tables processed in the inner loops typically are read many times. 
      

  2.   

    JOIN_BUFFER 和 SORT_BUFFER都可以在配置文件中配置 调优的时候可能会用到