Run
Run

Reputation: 57176

MySQL query: alternatives for INFORMATION_SCHEMA.TABLES

  1. Why does INFORMATION_SCHEMA.TABLES take ages to return result on my live server but not on my localhost? (I think it clashes my live server each time I perform this!)

  2. Any alternatives for INFORMATION_SCHEMA.TABLES to list all tables and numbers of record in each table?

Here is the query:

SELECT * 
FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA LIKE 'db_name'

What I need are only

<?php echo $item['TABLE_NAME'];?> (using INFORMATION_SCHEMA.TABLES)
<?php echo $item['TABLE_ROWS'];?> (using INFORMATION_SCHEMA.TABLES)

Thanks.

Upvotes: 0

Views: 2966

Answers (2)

Nicola Cossu
Nicola Cossu

Reputation: 56357

Take a look at

show table status

Upvotes: 0

Dlongnecker
Dlongnecker

Reputation: 3047

  1. Show Tables. Although doubtful this will be much faster than an information_schema query. Unless your network connection is dreadfully slow

  2. SELECT TABLE_NAME, TABLE_ROWS
    FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA LIKE 'db_name'

Upvotes: 1

Related Questions