It is impossible to give a definitive answer with the information that we have, but start with them:
Do you have a pointer to key_1?
Without it, each request by itself will be slow, just looking for 123.
Do you have a pointer to (key_1, key_2)?
Because select distinct key_2 where key_1 = 123
really fast if it can get all the necessary data only from the index. No need to refer to the table.
Are rows / indexes fixed?
Moving a fixed-size table / row can be faster because it is always known where the xth record is by calculating the offset. Variable row size tables are slower.
Have you tried to add a surrogate auto-increment primary key?
Indexes work better when all they need to keep is a column and a small primary key. Complex primary keys are slower.
Did you read the table read-only?
You can pack the myisam table for quick access, but they become read-only. This is the hack that uses it.
Another step, do you consider a data warehouse?
If tables do not change frequently, it is best to duplicate information for quick access.
Can you post a show create table
statement? Observing columns and indexes will help. Can you post an explain select
statement? Seeing which indexes are used will help.
source share