List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:February 20 2008 8:35am
Subject:re: Record counts from handler::info()
View as plain text  

>>>>> "Timothy" == Timothy P Clark <Timothy> writes:

Timothy> Does the following comment from :: info() still hold in 5.1?
Timothy> /*
Timothy> ...
Timothy>   You will probably want to have the following in your code:
Timothy>     @code
Timothy>   if (records < 2)
Timothy>     records = 2;
Timothy>     @endcode
Timothy> ...
Timothy> */

Timothy> I ask because "DELETE FROM [TABLE];" appears to rely on the stats.records
Timothy> to report how many rows were deleted from a call to
Timothy> handler::delete_all_rows(). If my storage engine always sets stats.records
Timothy> to be >= 2, DELETE FROM will always report that at least two rows were
Timothy> deleted, even if the table was empty. Furthermore, I don't see MyISAM or
Timothy> InnoDB implementing this logic.

We need the above, because the SELECT optimizer trusts that the handler gives
a correct row count if the info method returns 0 or 1.

(It's used to optimize the two common case where the table is empty or
has 1 row)

Record counts from handler::info()Timothy P Clark18 Feb
  • Re: Record counts from handler::info()Stewart Smith20 Feb
  • re: Record counts from handler::info()Michael Widenius20 Feb
    • Re: re: Record counts from handler::info()Sergei Golubchik20 Feb
      • Re: Record counts from handler::info()Brian Aker20 Feb