limit
Limits the number of output records by cancelling the query when the specified count is reached.
Command properties
| Property | Value |
|---|---|
| Command type | Transforming |
| Required permission | None |
| License usage | N/A |
| Parallel execution | Supported |
| Distributed execution | Runs on Control Node (reducer) |
Syntax
limit [OFFSET] COUNT
Target
[OFFSET]- Number of records to skip. Defaults to 0 if omitted.
COUNT- Maximum number of records to output.
Error codes
Parsing errors
| Error code | Message | Description |
|---|---|---|
| 20600 | 오프셋은 1개 또는 2개 입니다. | No argument or more than 2 arguments |
| 20601 | 잘못된 오프셋 타입입니다: [msg] | An argument is not an integer |
Runtime errors
N/A
Description
The limit command skips OFFSET records from the input, outputs COUNT records, then cancels the query. Be careful when placing aggregation commands after limit in the query pipeline, as they may not work as intended when the query is cancelled mid-execution.
In a distributed environment, this command runs on Control Nodes.
Examples
-
Retrieve the top 10 records
table duration=1h WEB_LOGS | limit 10Outputs only 10 records from the last 1 hour of web logs.
-
Specify skip count and output count
table duration=1h WEB_LOGS | limit 100 10Skips 100 records and then outputs 10 records.
-
Extract the top records from inline data
json "[{'name': 'Alice'}, {'name': 'Bob'}, {'name': 'Charlie'}, {'name': 'David'}]" | limit 2Outputs only the first 2 records.