Using LIMIT ROWS EXAMINED
The LIMIT ROWS EXAMINED
clause is a good way to minimize the overhead of a very large or otherwise expensive query if we don't necessarily want or need to search every row in a large table or set of tables.
Getting ready
Import the ISFDB
database as described in the Importing the data exported by mysqldump recipe, earlier in this chapter.
How to do it...
Open a terminal window and launch the
mysql
command-line client and connect to theisfdb
database.Run the following query from the Using SHOW EXPLAIN with running queries recipe, with one small addition at the end:
SELECT titles.title_id AS ID, titles.title_title AS Title, authors.author_legalname AS Name, (SELECT COUNT(DISTINCT title_relationships.review_id) FROM title_relationships WHERE title_relationships.title_id = titles.title_id) AS reviews FROM titles,authors,canonical_author WHERE (SELECT COUNT(DISTINCT title_relationships.review_id) FROM title_relationships...