# LIMIT

The LIMIT command restricts the number of rows returned by a query. It is useful for controlling the size of the result set, especially when working with large datasets.

## Syntax

`LIMIT max_number_of_rows`

### Parameters

#### max_number_of_rows

The maximum number of rows to return.

## Examples

Returns the first 5 employees after sorting all employees by their employee number in ascending order.

```esql
FROM employees
| SORT emp_no ASC
| LIMIT 5
```

## Limitations

Queries do not return more than 10,000 rows, regardless of the LIMIT value. This is a configurable upper limit. The default and maximum limits can be changed using the dynamic cluster settings `esql.query.result_truncation_default_size` and `esql.query.result_truncation_max_size`. Increasing these limits may result in higher memory usage, longer processing times, and increased internode traffic. The upper limit applies only to the number of rows output by the query, not to the number of documents processed.
