MySQL Forums
Forum List  »  Performance

Re: Index Not being used.
Posted by: Rick James
Date: May 31, 2016 09:26PM

You have aggregates (SUM) and no GROUP BY? So, you should get one line of output. Yet, you are saying it returns millions of rows.

If it does return millions of rows, what will you do with them? That is a lot to process. Can you 'process' them in sql, and return some smaller resultset.

If ORD_DATE is in the `lines` table, why have `LEFT`? The WHERE clause will exclude them anyway. Once you remove `LEFT`, the optimizer is free to start with `lines`. But then you need these two indexes:

pos_ord_headers: INDEX(ORD_ID) -- perhaps you already have it as a PRIMARY KEY.
pos_ord_lines: INDEX(ORD_DATE)

Options: ReplyQuote


Subject
Views
Written By
Posted
3009
May 26, 2016 02:29PM
1368
May 26, 2016 03:53PM
1192
May 27, 2016 12:45AM
1124
May 27, 2016 07:05AM
1133
May 27, 2016 11:29PM
1239
May 31, 2016 07:04AM
Re: Index Not being used.
1081
May 31, 2016 09:26PM
1139
June 01, 2016 05:40AM
933
June 01, 2016 11:29AM
1181
June 01, 2016 11:41AM
1119
June 04, 2016 05:14PM
1126
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.