MySQL Forums
Forum List  »  Performance

Index Not being used.
Posted by: Greg Mundt
Date: May 26, 2016 02:29PM

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?

Options: ReplyQuote


Subject
Views
Written By
Posted
Index Not being used.
1107
May 26, 2016 02:29PM
562
May 26, 2016 03:53PM
510
May 27, 2016 12:45AM
482
May 27, 2016 07:05AM
434
May 27, 2016 11:29PM
572
May 31, 2016 07:04AM
451
May 31, 2016 09:26PM
524
June 01, 2016 05:40AM
391
June 01, 2016 11:29AM
444
June 01, 2016 11:41AM
459
June 04, 2016 05:14PM
509
May 27, 2016 10:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.