title: MySQL index for MIN and MAX
body: <p>Could anyone clarify this point from the official MySQL <a href="https://dev.mysql.com/doc/refman/5.7/en/mysql-indexes.html" rel="noreferrer">documentation</a></p>
  
  <blockquote>
    <p>Indexes are used ... To find the MIN() or MAX() value for a specific indexed column key_col. This is optimized by a preprocessor that checks whether you are using WHERE key_part_N = constant on all key parts that occur before key_col in the index. In this case, MySQL does a single key lookup for each MIN() or MAX() expression and replaces it with a constant. If all expressions are replaced with constants, the query returns at once. For example: <em>SELECT MIN(key_part2),MAX(key_part2) FROM tbl_name WHERE key_part1=10;</em></p>
  </blockquote>
  
  <p>So in their exampe they're trying to find the min and max values of the col called key_col. Are they using a composite index key_part1_key_part2? Does key_part2 part of the index represent key_col column?</p>
  
  <p>I absolutely don't understand what they're trying to say of replacing the expressions by the constant. Could you help me to work out this point?</p>
  
  <p><strong>UPDATE:</strong> The question is not about how the <code>WHERE</code> statement or indexes work on the "highest levels", if I can say that. I was confused by this processor's expression replacing thing in this certain point about MIN and MAX.</p>