You may find what I am about to suggest a little surprising
Add the following indexes
ALTER TABLE mytable ADD INDEX id_value_ndx (id,value);
ALTER TABLE mytable ADD INDEX value_id_ndx (value,id);
This will actually cache id and value together in the MyISAM Key Cache. That way, all queries are in memory only. Queries will not go to the table at all.
I would also propose you make a dedicated 1GB MyISAM Key Cache just for your table
STEP 01: Create a script to load the table into the dedicated key cache
cd /var/lib/mysql
echo "SET GLOBAL mykeycache.key_buffer_size = 1024 * 1024 * 1024;" > init-file.sql
echo "CACHE INDEX mytable IN mykeycache; >> init-file.sql
echo "LOAD INDEX INTO CACHE mykeycache; >> init-file.sql
STEP 02 : Add this to /etc/my.cnf
[mysqld]
init-file=/var/lib/mysql/init-file/sql
STEP 03 : service mysql restart
From here on, every restart of mysql will setup this private key cache for your table
Give it a Try !!!
The answer depends on what you intend to do with the data. Are you going to be doing frequent queries against it or do you only need it for the occasional lookup of what happened when, to rollback bad changes, or for regulatory reasons?
In the first case above, use the second process you descibed although I would add a column to denote the active record. I would also add a record created date. I wouild also create a view of just the active records and use that for allof my code that needs to see the current data.
In the second case above, I would have audit tables that are populated through triggers (the offective way to create audit records for any change to the db) and that also include the data of the change and the user or application that made the change as well as the old and new values.
Best Answer
SUGGESTION #1
Based on the
WHERE
clause, I highly recommend a compound indexThat way, all parts of the
WHERE
clause are answered by the index.SUGGESTION #2
Since you are imposing a limit of 200, collect the 200 keys first, then join the keys
I have suggested this technique before in StackOverflow
GIVE IT A TRY !!!