LIMIT clause
Simple Log Service returns 100 rows by default. Use the LIMIT clause to specify a different number of rows to return.
Syntax
The LIMIT clause supports two formats.
-
Return the first x rows.
LIMIT x -
Return x rows starting from offset y.
LIMIT y, x
-
The LIMIT clause applies only to final results, not intermediate results within a SQL query.
-
The
LIMIT y,xclause is not supported inside a subquery. For example, the following statement is invalid:* | select count(1) from ( select distinct(url) from limit 0,1000).
Parameters
|
Parameter |
Description |
|
x |
The number of rows to return.
|
|
y |
The number of rows to skip. Valid range: [0, 1,000,000]. |
The sum of x and y cannot exceed 1,000,000.
Examples
-
Return the first 200 rows from the result set.
-
Query statement
* | SELECT request_time LIMIT 200 -
Result: Returns 200 values from the
request_timefield, such as 60.0, 63.0, and 73.0.
-
-
Return 1,000 rows with an offset of 100.
-
Query statement
* | SELECT request_time LIMIT 100,1000 -
Result: Returns 1,000 values from the
request_timefield, with an offset of 100.
-
-
Return the top three request URIs with the longest request times.
-
Query statement
* | SELECT request_uri AS top_3, request_time ORDER BY request_time DESC LIMIT 3 -
Result: Returns the three URIs with the longest request times:
/request/path-3/file-2(80.0),/request/path-2/file-4(80.0), and/request/path-0/file-8(79.0).
-