Bonjour,
J'ai lu qu'il y avait un petit souci avec la fonction ci-dessous en InnoDb:
SELECT COUNT(*) From maTable;
Vu ici:
http://dev.mysql.com/doc/refman/5.0/...trictions.html
InnoDB does not keep an internal count of rows in a table because concurrent transactions might “see” different numbers of rows at the same time. To process a SELECT COUNT(*) FROM t statement, InnoDB must scan an index of the table, which takes some time if the index is not entirely in the buffer pool. If your table does not change often, using the MySQL query cache is a good solution. To get a fast count, you have to use a counter table you create yourself and let your application update it according to the inserts and deletes it does. If an approximate row count is sufficient, SHOW TABLE STATUS can be used. See Section 13.2.13.1, “InnoDB Performance Tuning Tips”.
Je ne suis pas sure de tout comprendre... Est ce que cela veut dire qu'en utilisant des requetes de ce type:
SELECT Count(clefPrimaire) FROM maTable WHERE colone='toto';
Il n'y a pas de problème?
Je ne veux pas trop m'avancer mais je crois comprendre que:
- COUNT(*) est plus rapide que COUNT(clefPrimaire)
- COUNT(*) ne renvoie pas forcement la bonne valeur car il n'y a pas de table qui maintient un compteur (Tout ca pour permettre les transactions)
Je ne sais plus quoi utiliser...
Partager