If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > How many records?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-09-04, 18:49
Matrix28 Matrix28 is offline
Registered User
 
Join Date: Sep 2003
Posts: 47
How many records?

I have a large database and need to find how many records it contains, (it gets update very often) and print it to our page (Via perls DBI). The problems is, doing a SELECT * from everytime takes resources. Is there a function to just find how many records a database has without quering it all the time?
Reply With Quote
  #2 (permalink)  
Old 08-09-04, 19:03
ServerMetrics ServerMetrics is offline
Registered User
 
Join Date: May 2004
Posts: 45
You should use the "SELECT COUNT(*) FROM tablename" or else use the SHOW TABLE STATUS command, as in "SHOW TABLE STATUS LIKE 'tablename'" and look for the column 'Rows'. This works fine on MyISAM tables but if you are using InnoDb tables the SELECT COUNT(*) will have the same performance impact you are currently experiencing since it will also do a full table scan.
__________________
Keith Brownlow
ServerMetrics DB Monitoring (www.servermetrics.com)
Reply With Quote
  #3 (permalink)  
Old 08-10-04, 04:16
Matrix28 Matrix28 is offline
Registered User
 
Join Date: Sep 2003
Posts: 47
Thanks!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On