jeudi 26 mars 2015

SELECT COUNT(*) expensive query mysql?


I have following query:



SELECT COUNT(*) AS `numrows`
FROM (`phppos_items`)
WHERE `deleted` = 0


explain:



mysql> explain SELECT COUNT(*) AS `numrows`
-> FROM (`phppos_items`)
-> WHERE `deleted` = 0;
+----+-------------+--------------+------+---------------+---------+---------+-------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+------+---------------+---------+---------+-------+------+-------------+
| 1 | SIMPLE | phppos_items | ref | deleted | deleted | 4 | const | 1 | Using index |
+----+-------------+--------------+------+---------------+---------+---------+-------+------+-------------+


Will this query always be indexed AND fast as the rows in the table grow?





Aucun commentaire:

Enregistrer un commentaire