I have a table TEST with two columns:
- A varchar(250)
- B tinyint(1)
The table has about 4 million rows. A contains UTF8 strings, B can only be 0 or 1.
select count(1) from TEST is very fast (as of MySQL Workbench 0,000 sec), but select count(1) from TEST where B=1 takes about 15 seconds (on a quite fast machine, but on a real table with more columns that should not matter for this problem). Adding an index for B did not help - it still makes a full table scan. Forcing the index usage did not help neither.
The storage engine is MyISAM and because there are much, much more selects than inserts/updates, this is probably the best choice.
How can this query be speeded up?