MySQL Forums
Forum List  »  Full-Text Search

Re: Multiple Databases - Search and retrieve.
Posted by: Rick James
Date: July 11, 2011 11:26AM

> SELECT SQL_CALC_FOUND_ROWS name, email FROM users WHERE name LIKE 'a%' LIMIT 10;
> SELECT FOUND_ROWS();
If you have an plain index (I don't mean FULLTEXT) on `name`, that format is more efficient. It will first pick a random 10 rows where name starts with a. Since you are asking for more than just the name, it will hit 10 data rows. The, to get the FOUND_ROWS, it will continue using only then index.

If you do LIKE '%a' (leading wildcard), performance suffers because it will require an index scan.

If you have more than 10K databases, or 10K tables in a single database, or 100M rows in a table, then performance issues increase. 7 is no problem; 70K would be a problem.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Multiple Databases - Search and retrieve.
2485
July 11, 2011 11:26AM


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.