Forum Moderators: open
My question is, should I index the `status` field?
What it does is define whether the product should be shown on the site or not. I'll be search like so:
select * from products where category = 12 and status = 1;
Here is the DB so far:
mysql> explain products;
+----------+-------------+------+-----+---------+-------+
¦ Field ¦ Type ¦ Null ¦ Key ¦ Default ¦ Extra ¦
+----------+-------------+------+-----+---------+-------+
¦ id ¦ varchar(30) ¦ ¦ PRI ¦ ¦ ¦
¦ category ¦ int(11) ¦ ¦ MUL ¦ 0 ¦ ¦
¦ name ¦ varchar(50) ¦ ¦ ¦ ¦ ¦
¦ descrip ¦ text ¦ ¦ ¦ ¦ ¦
¦ cost ¦ float(6,2) ¦ ¦ ¦ 0.00 ¦ ¦
¦ status ¦ tinyint(1) ¦ ¦ ¦ 1 ¦ ¦
+----------+-------------+------+-----+---------+-------+
6 rows in set (0.02 sec)
It's not a huge table but I still want it to be as efficient as possible.
Just in case you weren't aware, mysql.com has nice documentation on mysql optimization [dev.mysql.com] if your willing to take a look :)
Good luck!