The limit operator in Axiom Processing Language (APL) allows you to restrict the number of rows returned from a query. It is 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 is not 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.

Usage

Syntax

| limit [N]

Parameters

  • N: The maximum number of rows to return. This must be a non-negative integer.

Returns

The limit operator returns the top N rows from the input dataset. If fewer than N rows are available, all rows are returned.

Use case examples

In log analysis, you often want to view only the most recent entries, and limit can help narrow the focus on those rows.

Query

['sample-http-logs']
| limit 5

Run in Playground

Output

_timereq_duration_msidstatusurimethodgeo.citygeo.country
2024-10-17T12:00:00200123200/index.htmlGETNew YorkUSA
2024-10-17T11:59:59300124404/notfound.htmlGETLondonUK

This query limits the output to the first 5 rows from the ['sample-http-logs'] dataset, returning recent HTTP log entries.

  • take: Similar to limit, but explicitly focuses on row sampling.
  • top: Retrieves the top N rows sorted by a specific field.
  • sample: Randomly samples N rows from the dataset.