MySQL Forums
Forum List  »  Backup

Re: Backup and trimming data idea
Posted by: Rick James
Date: June 28, 2012 11:19PM

> or make it a separate index is better
The simple answer is "never". The optimizer almost never uses more than one INDEX in a query.

> index(a,b) or index(b,a) is there any difference
Think about fields last_name and first_name. Let's say you have
INDEX(last_name, first_name)
like in a Phone Directory. How, let's say you want
WHERE last_name LIKE 'J%' and first_name = 'Rick'
That index would be useless, but this would be useful:
INDEX(first_name, last_name)

If you want
WHERE last_name = 'James' and first_name = 'Rick'
then either ordering would work equally well.

My kinfolk can be found efficiently via
INDEX(last_name, first_name) _or_ INDEX(last_name)
WHERE last_name = 'James'

If you have two _separate_ SELECTs with
WHERE last_name = 'James'
WHERE first_name = 'Rick'
Then you need two _separate_ indexes:
INDEX(last_name, ...)
INDEX(first_name, ...)
(I say "..." because, for this example, extra columns in the indexes are optional.)

Deleting lots of data (including use of PARTITION for such):
http://mysql.rjweb.org/doc.php/deletebig

Options: ReplyQuote


Subject
Views
Written By
Posted
3508
June 22, 2012 07:34PM
1687
June 23, 2012 05:23PM
1745
June 23, 2012 05:36PM
1762
June 24, 2012 01:51PM
1796
June 25, 2012 10:16AM
1650
June 26, 2012 08:14AM
1746
June 26, 2012 08:46AM
1630
June 27, 2012 08:36AM
1730
June 27, 2012 09:03AM
Re: Backup and trimming data idea
1592
June 28, 2012 11:19PM
1546
June 29, 2012 07:12AM
1549
June 30, 2012 11:50AM
1625
July 02, 2012 09:47AM
1567
July 03, 2012 01:32PM
1614
July 05, 2012 11:13AM
1783
July 06, 2012 09:57AM
1572
July 07, 2012 10:50AM
1594
July 08, 2012 09:33AM
1584
July 16, 2012 08:08PM
1564
July 21, 2012 10:57PM


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.