• unknown's avatar
    Bug#31700: thd->examined_row_count not incremented for 'const' type queries · a41b4763
    unknown authored
    UNIQUE (eq-ref) lookups result in table being considered as a "constant" table.
    Queries that consist of only constant tables are processed in do_select() in a
    special way that doesn't invoke evaluate_join_record(), and therefore doesn't
    increase the counters join->examined_rows and join->thd->row_count.
    
    The patch increases these counters in this special case.
    
    NOTICE:
    This behavior seems to contradict what the documentation says in Sect. 5.11.4:
    "Queries handled by the query cache are not added to the slow query log, nor
    are queries that would not benefit from the presence of an index because the
    table has zero rows or one row."
    
    No test case in 5.0 as issue shows only in slow query log, and other counters
    can give subtly different values (with regard to counting in create_sort_index(),
    synthetic rows in ROLLUP, etc.).
    
    
    sql/sql_class.h:
      add documentation for some variables
    sql/sql_select.cc:
      Don't forget const tables when counting read records!
    a41b4763
sql_select.cc 495 KB