> I've got a query that selects the count of distinct rows in a table; the > table has 453632 rows and 24 distinct class_id's. > > mysql> SELECT count(DISTINCT(sig_class_id)) FROM acid_event; > +-------------------------------+ > | count(DISTINCT(sig_class_id)) | > +-------------------------------+ > | 24 | > +-------------------------------+ > 1 row in set (4.80 sec) > > mysql> select count(*) FROM acid_event; > +----------+ > | count(*) | > +----------+ > | 453632 | > +----------+ > 1 row in set (3.12 sec) > > > Is there any way to speed up these queries (InnoDB tables), or just put up?
If you are using a version of MySql that has the query cache you can turn it on and those queries will run very fast after the initial query. The query cache is cleared whenever the underlying table(s) are modified so you'll get the initial time hit again after modification...but if your table contents don't change much the query cache will make a BIG difference. Peter <^_^> --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php