If you go to newegg.com (just one example) you’ll notice while browsing products you can see the number of items next to each product attribute in the left hand sidebar.
With so many attributes on some items and so many different configurations of product filters how do they calculate all of those totals so fast?
For newegg.com, they are using a faceted navigation technology provided by endeca
In nutshell, endeca will actually use the data provided in xml/csv or directly retrieve data from any database (not limited to just mysql) and calculate similarity and group the result into their own format
Endeca is not free, the open-source alternative such as sphinx or lucene solr