0

Is there a faster method to get the record number of a huge mysql table (~3 mil rows) ?

I don't want to list them, only to get the total.

Thanks

keepwalking
  • 2,644
  • 6
  • 28
  • 63
  • 1
    Same question answered here: http://stackoverflow.com/questions/5060366/mysql-fastest-way-to-count-number-of-rows – HRgiger Sep 19 '11 at 16:33

3 Answers3

3
SELECT COUNT(id) AS total FROM table;
usoban
  • 5,428
  • 28
  • 42
0
SELECT COUNT(id) FROM tbl;

If "id" is an index this should be pretty fast.

If you use a WHERE too, the index has to be a covering index (contain all rows in one index)

See http://peter-zaitsev.livejournal.com/6949.html

Bluewind
  • 1,054
  • 7
  • 10
0

You could just say:

SELECT COUNT(*) FROM TABLE;

That should display the number of records in the table.

Faheem
  • 1,423
  • 2
  • 13
  • 22