# Batch Size

+ A chunk contains multiple rows of data. When an SQL statement is executed, the executor performs data acquisition, expression evaluation, and JOIN operations in chunk units. When the result set is large, a larger chunk size can improve performance. If the result set is small and less than the chunk size, applying for too large chunk memory will cause loss of performance.

![left](./student-guide/diagram/06-batch-size-01-01.png)
------------------------------------------------------------
Batch size

- A chunk contains multiple rows of data. When an SQL statement is executed, the executor performs data acquisition, expression evaluation, and JOIN operations in chunk units. When the result set is large, a larger chunk size can improve performance. If the result set is small, less than the chunk size, the memory of an oversized chunk will be requested. Causing a loss of performance

- tidb_init_chunk_size/tidb_max_chunk_size
  - When an operator is executed, a chunk of tidb_init_chunk_size is created for the first time. When the result set is larger than the initial chunk size, the chunk size will be scale out the next time it is executed, and the size of the chunk size will be increased. If the result set still exceeds the chunk size, it will be expanded again. capacity until the upper limit set by tidb_max_chunk_size is reached

- tidb_index_join_batch_size
  - Control the amount of data processed by the index join operator in a batch. Setting a larger size may improve performance at the cost of consuming more memory
