LIMIT Clause

The LIMIT clause is used to specify the maximum number of rows to return for a query.

The following code shows the syntax of the LIMIT clause supported by ActiveSpaces:
LIMIT <rowcount expression>
The LIMIT clause affects the number of result rows for the query. The LIMIT clause, if specified, must be the last clause of the SELECT statement and is the last clause applied to a query. In other words, the LIMIT clause is applied after the WHERE clause is applied, the GROUP BY clause is applied, and the ORDER BY clause is applied. The LIMIT clause does not affect the number of rows scanned for a query.

LIMIT Clause and Full Table Scan Property

When the WHERE clause of a SELECT statement does not refer to the primary key or secondary indexes of a table, the entire table must be scanned to find the rows of the table that is returned for a query. This process of scanning the entire table is known as a full table scan. When a LIMIT clause is appended to a SELECT statement, it does not affect whether or not a full table scan is performed. However, the LIMIT clause affects the number of results returned for the query, but not how many rows are scanned for a table. The rows resulting from the scan might then also need to be grouped with a GROUP BY clause and then sorted with ORDER BY clauses. The final set of result rows are then limited by the count specified for the LIMIT clause.