MySQL Example Scripts for “Partial Results”


This section contains the create and insert statements to run the examples from Chapter 7, “Partial Results” in a MySQL database.

Querying Top-N Rows

An indexed Top-N query doesn’t show a “filesort” operation in the Extras column:

SELECT *
  FROM sales
 ORDER BY sale_date DESC
 LIMIT 10;

+----+-------+-------+-------------+--------+-------+
| id | table | type  | key         | rows   | Extra |
+----+-------+-------+-------------+--------+-------+
|  1 | sales | index | sales_dt_pr | 836092 |       | 
+----+-------+-------+-------------+--------+-------+

About the Author

As an author, trainer, and coach Markus Winand specializes in helping developers cope with SQL performance issues. He also published the book SQL Performance Explained and tweets his best performance tips via @SQLPerfTips.http://winand.at/

Recent Questions at Ask.Use-The-Index-Luke.com

0
votes
1
answer
62
views
0
votes
0
answers
314
views

Fanout in R-Tree

Mar 27 at 08:07 jamie 1
tree indexing
0
votes
1
answer
98
views

Think About It

Mar 26 at 12:54 Markus Winand ♦♦ 511
reflection