Book Image

MariaDB Cookbook

By : Daniel Bartholomew
Book Image

MariaDB Cookbook

By: Daniel Bartholomew

Overview of this book

Table of Contents (20 chapters)
MariaDB Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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...

  1. Open a terminal window and launch the mysql command-line client and connect to the isfdb database.

  2. 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...