| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
LIMIT
In some cases MySQL will handle the query differently when you are
using LIMIT row_count and not using HAVING:
LIMIT, MySQL
will use indexes in some cases when it normally would prefer to do a
full table scan.
LIMIT row_count with ORDER BY, MySQL will end the
sorting as soon as it has found the first row_count lines instead of sorting
the whole table.
LIMIT row_count with DISTINCT, MySQL will stop
as soon as it finds row_count unique rows.
GROUP BY can be resolved by reading the key in order
(or do a sort on the key) and then calculate summaries until the
key value changes. In this case LIMIT row_count will not calculate any
unnecessary GROUP BY values.
# rows to the client, it
will abort the query (if you are not using SQL_CALC_FOUND_ROWS).
LIMIT 0 will always quickly return an empty set. This is useful
to check the query and to get the column types of the result columns.
LIMIT row_count is used to calculate how much space is required.