El 29/12/2011 3:29, 晓磊 贾 escribió/wrote:
> hi, all:
>
> Most of time, if you want to get the records of a table, 'select
> count(*) from [table_name]' is okay.
> While, I find use " select TABLE_NAME, PARTITION_NAME, TABLE_ROWS,
> AVG_ROW_LENGTH, DATA_LENGTH from INFORMATION_SCHEMA.PARTITIONS where
> TABLE_SCHEMA = 'LN_PABB2' and TABLE_NAME='T_BOUND' ;" get a different
> table_rows.
> Is anyone encounter with the problem?
It's actually documented. The MyISAM engine tracks the exact row count
but the InnoDB engine does not. Running a COUNT(*) SQL query is the only
exact method that works for all engines.
http://dev.mysql.com/doc/refman/5.5/en/show-table-status.html
«Some storage engines, such as MyISAM, store the exact count. For other
storage engines, such as InnoDB, this value is an approximation, and may
vary from the actual value by as much as 40 to 50%. In such cases, use
SELECT COUNT(*) to obtain an accurate count.»
--
--
http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
http://borrame.com
-- Mi web de humor satinado:
http://www.demogracia.com
--