0

I have a question. I want to show the number of registered user on my site.

i already tried to make this query:

select count(*) from members

and then show the result of the count. but for big table.. it's not good idea i think

but i think it's not optimize.. when i do an explain, the query reads all rows... i suppose that's normal to counts the numbers of members

But is there a best way to do it for performance and optimization? Thanks a lot

Pascal
  • 37
  • 6
  • For most database engines, selecting the count of a table is instantaneous. It doesn't actually count how many rows there are. It has an internal row count for every table and just spits that value out. – kainaw Jun 02 '15 at 19:17
  • It's optimized for MyISAM, but not for InnoDB. – Barmar Jun 02 '15 at 19:19
  • COUNT(*) is the fastest. possible, equal to count(1) http://stackoverflow.com/questions/6069237/fastest-way-to-count-exact-number-of-rows-in-a-very-large-table – Alex Jun 02 '15 at 19:19
  • ok perfect! Thanks a lot ! I didnt see that post! – Pascal Jun 03 '15 at 12:27

0 Answers0