dbTalk Databases Forums  

table_rows of a table

comp.databases.mysql comp.databases.mysql


Discuss table_rows of a table in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
晓磊 贾
 
Posts: n/a

Default table_rows of a table - 12-28-2011 , 08:29 PM






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?

#NOTE: the results using different sql:


+---------------------------+----------------+------------
+----------------+-------------+
Quote:
TABLE_NAME | PARTITION_NAME | TABLE_ROWS |
AVG_ROW_LENGTH | DATA_LENGTH |
+---------------------------+----------------+------------
+----------------+-------------+
Quote:
T_ADMINISTRATOR | NULL | 0
0 | 16384 |
T_ADMINISTRATOR_LOGIN_LOG | NULL | 0
0 | 16384 |
T_ADMINISTRATOR_SOURCE | NULL | 5 |
3276 | 16384 |
T_AREA_PRIVILEGE | NULL | 0
0 | 16384 |
T_BOUND | NULL | 8182737
95 | 781189120 |
T_BOUND_DATA | NULL | 16365429
56 | 918552576 |
T_BOUND_EVENT | NULL | 10144037
86 | 880820224 |
....


mysql> select count(id) from T_BOUND_EVENT ;
+-----------+
Quote:
count(id) |
+-----------+
10000001 |
+-----------+
1 row in set (10.05 sec)


mysql> select count(id) from T_BOUND_EVENT ;
+-----------+
Quote:
count(id) |
+-----------+
10000001 |
+-----------+
1 row in set (10.05 sec)

mysql> select count(id) from T_BOUND ;
+-----------+
Quote:
count(id) |
+-----------+
8182546 |
+-----------+
1 row in set (6.26 sec)

mysql> select count(*) from T_BOUND ;
+----------+
Quote:
count(*) |
+----------+
8182546 |
+----------+
1 row in set (1.82 sec)

mysql> select count(*) from T_BOUND ;
+----------+
Quote:
count(*) |
+----------+
8182546 |
+----------+
1 row in set (0.00 sec)

-- Jia Xiaolei

Reply With Quote
  #2  
Old   
Lennart Jonsson
 
Posts: n/a

Default Re: table_rows of a table - 12-29-2011 , 12:38 AM






On 2011-12-29 03:29, 晓磊 贾 wrote:
Quote:
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?
TABLE_ROWS is only an approximation, so you can't use it if you need
exact numbers.


/Lennart

Reply With Quote
  #3  
Old   
Álvaro G. Vicario
 
Posts: n/a

Default Re: table_rows of a table - 12-29-2011 , 02:23 AM



El 29/12/2011 3:29, 晓磊 贾 escribió/wrote:
Quote:
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/...le-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
--

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.