limit operator in Axiom Processing Language (APL) allows you to restrict the number of rows returned from a query. It’s particularly useful when you want to see only a subset of results from large datasets, such as when debugging or previewing query outputs. The limit operator can help optimize performance and focus analysis by reducing the amount of data processed.
Use the limit operator when you want to return only the top rows from a dataset, especially in cases where the full result set isn’t necessary.
For users of other query languages
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.Splunk SPL users
Splunk SPL users
In Splunk, the equivalent to APL’s 
limit is the head command, which also returns the top rows of a dataset. The main difference is in the syntax.ANSI SQL users
ANSI SQL users
In ANSI SQL, the 
LIMIT clause is equivalent to the limit operator in APL. The SQL LIMIT statement is placed at the end of a query, whereas in APL, the limit operator comes after the dataset reference.Usage
Syntax
Parameters
N: The maximum number of rows to return. This must be a non-negative integer up to 50,000.
The maximum value for 
N is 50,000 rows. If you need to export or process more than 50,000 rows, consider using pagination with time-based filtering or the API endpoints with cursor-based pagination.Returns
Thelimit operator returns the top N rows from the input dataset. If fewer than N rows are available, all rows are returned.
Use case examples
- Log analysis
 - OpenTelemetry traces
 - Security logs
 
In log analysis, you often want to view only the most recent entries, and Run in PlaygroundOutput
This query limits the output to the first 5 rows from the 
limit can help narrow the focus on those rows.Query| _time | req_duration_ms | id | status | uri | method | geo.city | geo.country | 
|---|---|---|---|---|---|---|---|
| 2024-10-17T12:00:00 | 200 | 123 | 200 | /index.html | GET | New York | USA | 
| 2024-10-17T11:59:59 | 300 | 124 | 404 | /notfound.html | GET | London | UK | 
['sample-http-logs'] dataset, returning recent HTTP log entries.