Hi I have a MySQL table, let's say it is a helpdesk ticketing system. It has a CLOSED column, which I want to index. 99% of time, I will need to only select on OPEN tickets, so something like
"SELECT * FROM TICKET_TABLE where CLOSED='N'; "
And over time, more and more tickets are CLOSED, while a small constant number of OPEN tickets remain. OPEN/CLOSED ratio is like 1/99.
I have an index
ALTER TABLE TICKET_TABLE ADD INDEX ( CLOSED );
But this index is not chosen ( I have a bunch of other indexes, which get chosen when I do EXPLAIN ). I can understand this CLOSED index is not good when I query
"SELECT * FROM TICKET_TABLE where CLOSED='Y'; "
but it's perfect when I query
"SELECT * FROM TICKET_TABLE where CLOSED='N'; "
How should I index my table?