Index Not being used.
I am running MySQL 5.5 I have a table ord_headers that has 19,456,300 rows. It is in ISAM format. I have an index ORD_Date with Type BTREE, Unique No, Columns ORD_Date. When I do the following:
EXPLAIN
SELECT
ORD_Item,
ORD_Desc,
ORD_Item_Class,
SUM(ORD_Qty),
SUM(ROUND(ORD_Qty * ORD_Price, 2))
FROM
pos_ord_headers
LEFT JOIN
pos_ord_lines ON pos_ord_lines.ORD_ID = pos_ord_headers.ORD_ID
WHERE
ORD_Date>='2015-01-01' AND ORD_DATE<='2015-12-31';
I receive this:
id, select_type, table, type, possible_keys, key, key_len, ref, rows, Extra
'1', 'SIMPLE', 'pos_ord_headers', 'ALL', 'ORD_Date', NULL, NULL, NULL, '19456341', 'Using where'
'1', 'SIMPLE', 'pos_ord_lines', 'ref', 'PRIMARY', 'PRIMARY', '22', 'kilwins_pos.pos_ord_headers.ORD_ID', '446899', ''
So it sees the index of ORD_Date, but it shows NULL and when I put in a 12 month date range it runs for 10 minutes. Is there a way to address the indexes to get this performance down?