MySQL Forums
Forum List  »  Performance

Re: Best Index Strategy
Posted by: Rick James
Date: August 15, 2015 04:34PM

x LIKE '%...' -- This essentially eliminates any use of indexing on x. The performance goal is to avoid the leading '%'.

Would '%7600639533' work for your application? (That is, leading % only.) If so, you could
1. store REVERSE('917600639533') into the phone field (or a separate field,
2. INDEX that field: INDEX(address_type, rev_phone)
3. Get a lot of speed from
WHERE address_type = "billing"
AND (telephone LIKE CONCAT(REVERSE('7600639533', '%'));

Using FORCE INDEX may help the current case (with the current strings), but it may _hurt_ for some other strings. Use it only as a last resort.

> 3.16 sec vs 0.07

I suspect the larger number did not have everything cached in RAM, and the smaller one did. Did you run that query twice?

Please do this:
FLUSH STATUS;
SELECT ...;
SHOW SESSION STATUS LIKE 'Handler%';
for some of the options -- The Handler numbers can be very informative about whether it is doing full table scans, etc.

Options: ReplyQuote


Subject
Views
Written By
Posted
2042
August 09, 2015 11:35PM
812
August 10, 2015 07:02AM
764
August 10, 2015 07:17AM
743
August 10, 2015 11:30PM
741
August 12, 2015 10:53PM
Re: Best Index Strategy
711
August 15, 2015 04:34PM
715
August 16, 2015 11:53PM


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.