I have a table with 1394971 records, is it possible to optimize the count(*) performance?
mysql aDB -e 'select * from Table limit 1;'
0m0.034s
mysql aDB -e 'select count(*) from Table'
0m0.505s
Now, from mysql count performance and https://www.percona.com/blog/2006/12/01/count-for-innodb-tables/ :
So if you have query like SELECT COUNT(*) FROM USER It will be much faster for MyISAM (MEMORY and some others) tables because they would simply read number of rows in the table from stored value. Innodb will however need to perform full table scan or full index scan because it does not have such counter
I don't want to create an additional "counter" table.
Should I use another engine? Which one? I don't want to use MyISAM. Is this possible with other databases?