Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    47

    Unanswered: 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?

  2. #2
    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)

  3. #3
    Join Date
    Sep 2003
    Posts
    47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •