The LIMIT syntax is used to limit the number of rows returned in an SQL statement.
Syntax format
Log Service supports the following LIMIT syntax formats:- Reads only the first N rows:
limit N
- Reads N rows starting from the Sth row:
limit S , N
Note
- When you use the LIMIT syntax to paginate results, you get only the final results but not the intermediate results of the SQL query.
- The LIMIT syntax cannot be used in subqueries. For example, the following statement
is not supported:
* | select count(1) from (select distinct(url) from limit 0,1000)
- When you use the LIMIT syntax for pagination, the offset value cannot exceed 1,000,000.
That is, in the
limit S , N
statement, the sum of S and N cannot exceed 1,000,000, and the value of N cannot exceed 10,000.
Example
- To obtain only the first 100 rows of results, run the following statement:
* | select distinct(url) from log limit 100
- To obtain results from row 0 to row 999, totally 1,000 rows, run the following statement:
* | select distinct(url) from log limit 0,1000
- To obtain results from row 1,000 to row 1,999, totally 1,000 rows, run the following
statement:
* | select distinct(url) from log limit 1000,1000