I have a table:
mysql> describe table_1;
+---------------+------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+------------------+------+-----+---------------------+----------------+
| id | int(12) | NO | PRI | NULL | auto_increment |
| date | datetime | YES | | 0000-00-00 00:00:00 | |
| col1 | tinyint(1) | YES | | 1 | |
| col2 | longtext | YES | | NULL | |
| col3 | tinyint(1) | YES | | 1 | |
+---------------+------------------+------+-----+---------------------+----------------+
with the following characteristics:
mysql> select distinct(col1), count(col1) from table_1 group by col1;
+--------+---------------+
| col1 | count(col1) |
+--------+---------------+
| 0 | 200 |
| 1 | 689747 |
+--------+---------------+
How can I optimize queries like these, and with what kind of indexes?
1. SELECT * FROM table_1 WHERE col1 = 1
AND id NOT IN (79869) ORDER BY date DESC LIMIT 0, 10;
2. SELECT * FROM table_1 WHERE col1 = 1 AND id <> 18983
AND date > '2012-10-26' AND ( col2 LIKE '%word1%' OR col2 LIKE '%word2%')
ORDER BY date DESC LIMIT 5;